@salesforce/sf-plugins-core 1.9.0 → 1.11.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.11.1](https://github.com/salesforcecli/sf-plugins-core/compare/v1.11.0...v1.11.1) (2022-04-07)
6
+
7
+ ### Bug Fixes
8
+
9
+ - adjust message formats ([5b62ced](https://github.com/salesforcecli/sf-plugins-core/commit/5b62cedeb522c08dcce01159a22060be72c1bf62))
10
+
11
+ ## [1.11.0](https://github.com/salesforcecli/sf-plugins-core/compare/v1.10.0...v1.11.0) (2022-03-31)
12
+
13
+ ### Features
14
+
15
+ - support error codes help section ([4852a4f](https://github.com/salesforcecli/sf-plugins-core/commit/4852a4f75bcc744febf276293ed5bf45080436e6))
16
+
17
+ ## [1.10.0](https://github.com/salesforcecli/sf-plugins-core/compare/v1.9.0...v1.10.0) (2022-03-31)
18
+
19
+ ### Features
20
+
21
+ - warn users when using a beta command ([2cf26f2](https://github.com/salesforcecli/sf-plugins-core/commit/2cf26f2d363a40b0739f082bfe4aedd62fd4531f))
22
+
5
23
  ## [1.9.0](https://github.com/salesforcecli/sf-plugins-core/compare/v1.8.1...v1.9.0) (2022-03-24)
6
24
 
7
25
  ### Features
package/lib/exported.d.ts CHANGED
@@ -5,7 +5,7 @@ export { Deauthorizer } from './deauthorizer';
5
5
  export { Progress, Prompter, generateTableChoices } from './ux';
6
6
  export { SfHook } from './hooks';
7
7
  export * from './types';
8
- export { SfCommand, SfCommandInterface } from './sfCommand';
8
+ export { SfCommand, SfCommandInterface, StandardColors } from './sfCommand';
9
9
  export declare const Flags: {
10
10
  boolean: typeof import("@oclif/core/lib/parser/flags").boolean;
11
11
  directory: (opts?: ({
package/lib/exported.js CHANGED
@@ -20,7 +20,7 @@ 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.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.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; } });
@@ -38,6 +38,7 @@ Object.defineProperty(exports, "SfHook", { enumerable: true, get: function () {
38
38
  __exportStar(require("./types"), exports);
39
39
  var sfCommand_1 = require("./sfCommand");
40
40
  Object.defineProperty(exports, "SfCommand", { enumerable: true, get: function () { return sfCommand_1.SfCommand; } });
41
+ Object.defineProperty(exports, "StandardColors", { enumerable: true, get: function () { return sfCommand_1.StandardColors; } });
41
42
  // custom flags
42
43
  const orgFlags_1 = require("./flags/orgFlags");
43
44
  const salesforceId_1 = require("./flags/salesforceId");
@@ -1,12 +1,19 @@
1
1
  import { CliUx, Command, Config, HelpSection, Interfaces } from '@oclif/core';
2
2
  import { SfProject, StructuredMessage } from '@salesforce/core';
3
3
  import { AnyJson } from '@salesforce/ts-types';
4
+ import * as chalk from 'chalk';
4
5
  import { Progress, Prompter, Spinner, Ux } from './ux';
5
6
  export interface SfCommandInterface extends Interfaces.Command {
6
7
  configurationVariablesSection?: HelpSection;
7
8
  envVariablesSection?: HelpSection;
8
9
  errorCodes?: HelpSection;
9
10
  }
11
+ export declare const StandardColors: {
12
+ error: chalk.Chalk;
13
+ warning: chalk.Chalk;
14
+ info: chalk.Chalk;
15
+ success: chalk.Chalk;
16
+ };
10
17
  /**
11
18
  * A base command that provides convenient access to CLI help
12
19
  * output formatting. Extend this command and set specific properties
@@ -32,6 +39,13 @@ export declare abstract class SfCommand<T> extends Command {
32
39
  private lifecycle;
33
40
  protected get statics(): typeof SfCommand;
34
41
  constructor(argv: string[], config: Config);
42
+ /**
43
+ * Log a success message that has the standard success message color applied
44
+ *
45
+ * @param message
46
+ * @param args
47
+ */
48
+ logSuccess(message: string): void;
35
49
  /**
36
50
  * Log warning to users. If --json is enabled, then the warning
37
51
  * will be added to the json output under the warnings property.
@@ -104,7 +118,7 @@ export declare abstract class SfCommand<T> extends Command {
104
118
  protected assignProject(): Promise<SfProject>;
105
119
  protected catch(error: SfCommand.Error): Promise<SfCommand.Error>;
106
120
  /**
107
- * Format errors and actions for human consumption. Adds 'Error:',
121
+ * Format errors and actions for human consumption. Adds 'Error (<ErrorCode>):',
108
122
  * When there are actions, we add 'Try this:' in blue
109
123
  * followed by each action in red on its own line.
110
124
  * If Error.code is present it is output last in parentheses
package/lib/sfCommand.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SfCommand = void 0;
3
+ exports.SfCommand = exports.StandardColors = void 0;
4
4
  /*
5
5
  * Copyright (c) 2022, salesforce.com, inc.
6
6
  * All rights reserved.
@@ -10,10 +10,16 @@ exports.SfCommand = void 0;
10
10
  const os = require("os");
11
11
  const core_1 = require("@oclif/core");
12
12
  const core_2 = require("@salesforce/core");
13
- const chalk_1 = require("chalk");
13
+ const chalk = require("chalk");
14
14
  const ux_1 = require("./ux");
15
15
  core_2.Messages.importMessagesDirectory(__dirname);
16
16
  const messages = core_2.Messages.loadMessages('@salesforce/sf-plugins-core', 'messages');
17
+ exports.StandardColors = {
18
+ error: chalk.hex('BF0201'),
19
+ warning: chalk.hex('FF9A3C'),
20
+ info: chalk.dim,
21
+ success: chalk.hex('4BCA81'),
22
+ };
17
23
  /**
18
24
  * A base command that provides convenient access to CLI help
19
25
  * output formatting. Extend this command and set specific properties
@@ -36,6 +42,15 @@ class SfCommand extends core_1.Command {
36
42
  get statics() {
37
43
  return this.constructor;
38
44
  }
45
+ /**
46
+ * Log a success message that has the standard success message color applied
47
+ *
48
+ * @param message
49
+ * @param args
50
+ */
51
+ logSuccess(message) {
52
+ this.log(exports.StandardColors.success(message));
53
+ }
39
54
  /**
40
55
  * Log warning to users. If --json is enabled, then the warning
41
56
  * will be added to the json output under the warnings property.
@@ -44,8 +59,8 @@ class SfCommand extends core_1.Command {
44
59
  const colorizedArgs = [];
45
60
  this.warnings.push(input);
46
61
  const message = typeof input === 'string' ? input : input.message;
47
- colorizedArgs.push(`${chalk_1.default.bold.yellow(messages.getMessage('warning.prefix'))} ${message}`);
48
- colorizedArgs.push(...this.formatActions(typeof input === 'string' ? [] : input.actions || [], { actionColor: chalk_1.default.reset }));
62
+ colorizedArgs.push(`${exports.StandardColors.warning(messages.getMessage('warning.prefix'))} ${message}`);
63
+ colorizedArgs.push(...this.formatActions(typeof input === 'string' ? [] : input.actions || [], { actionColor: exports.StandardColors.info }));
49
64
  this.log(colorizedArgs.join(os.EOL));
50
65
  return input;
51
66
  }
@@ -55,8 +70,8 @@ class SfCommand extends core_1.Command {
55
70
  info(input) {
56
71
  const colorizedArgs = [];
57
72
  const message = typeof input === 'string' ? input : input.message;
58
- colorizedArgs.push(`${chalk_1.default.bold(messages.getMessage('info.prefix'))} ${message}`);
59
- colorizedArgs.push(...this.formatActions(typeof input === 'string' ? [] : input.actions || [], { actionColor: chalk_1.default.reset }));
73
+ colorizedArgs.push(`${exports.StandardColors.info(message)}`);
74
+ colorizedArgs.push(...this.formatActions(typeof input === 'string' ? [] : input.actions || [], { actionColor: exports.StandardColors.info }));
60
75
  this.log(colorizedArgs.join(os.EOL));
61
76
  }
62
77
  /**
@@ -140,6 +155,9 @@ class SfCommand extends core_1.Command {
140
155
  if (this.statics.requiresProject) {
141
156
  this.project = await this.assignProject();
142
157
  }
158
+ if (this.statics.state === 'beta') {
159
+ this.warn(messages.getMessage('warning.CommandInBeta'));
160
+ }
143
161
  this.lifecycle.onWarning(async (warning) => {
144
162
  this.warn(warning);
145
163
  });
@@ -193,7 +211,7 @@ class SfCommand extends core_1.Command {
193
211
  return error;
194
212
  }
195
213
  /**
196
- * Format errors and actions for human consumption. Adds 'Error:',
214
+ * Format errors and actions for human consumption. Adds 'Error (<ErrorCode>):',
197
215
  * When there are actions, we add 'Try this:' in blue
198
216
  * followed by each action in red on its own line.
199
217
  * If Error.code is present it is output last in parentheses
@@ -202,13 +220,12 @@ class SfCommand extends core_1.Command {
202
220
  */
203
221
  formatError(error) {
204
222
  const colorizedArgs = [];
205
- colorizedArgs.push(`${chalk_1.default.bold.red(messages.getMessage('error.prefix'))} ${error.message}`);
223
+ const errorCode = error.code ? ` (${error.code})` : '';
224
+ const errorPrefix = `${exports.StandardColors.error(messages.getMessage('error.prefix', [errorCode]))}`;
225
+ colorizedArgs.push(`${errorPrefix} ${error.message}`);
206
226
  colorizedArgs.push(...this.formatActions(error.actions || []));
207
227
  if (error.stack && core_2.envVars.getString(SfCommand.SF_ENV) === core_2.Mode.DEVELOPMENT) {
208
- colorizedArgs.push(chalk_1.default.red(`\n*** Internal Diagnostic ***\n\n${error.stack}\n******\n`));
209
- }
210
- if (error.code) {
211
- colorizedArgs.push(chalk_1.default.bold(`\n(${error.code})`));
228
+ colorizedArgs.push(exports.StandardColors.info(`\n*** Internal Diagnostic ***\n\n${error.stack}\n******\n`));
212
229
  }
213
230
  return colorizedArgs.join('\n');
214
231
  }
@@ -219,11 +236,11 @@ class SfCommand extends core_1.Command {
219
236
  * @param options
220
237
  * @private
221
238
  */
222
- formatActions(actions, options = { actionColor: chalk_1.default.red }) {
239
+ formatActions(actions, options = { actionColor: exports.StandardColors.info }) {
223
240
  const colorizedArgs = [];
224
241
  // Format any actions.
225
242
  if (actions === null || actions === void 0 ? void 0 : actions.length) {
226
- colorizedArgs.push(`\n${chalk_1.default.blue.bold(messages.getMessage('actions.tryThis'))}\n`);
243
+ colorizedArgs.push(`\n${exports.StandardColors.info(messages.getMessage('actions.tryThis'))}\n`);
227
244
  actions.forEach((action) => {
228
245
  colorizedArgs.push(`${options.actionColor(action)}`);
229
246
  });
package/lib/util.d.ts CHANGED
@@ -15,5 +15,5 @@ export declare type HelpSection = {
15
15
  * @param header
16
16
  * @param vars
17
17
  */
18
- export declare function toHelpSection(header: string, ...vars: Array<OrgConfigProperties | SfdxPropertyKeys | EnvironmentVariable | string>): HelpSection;
18
+ export declare function toHelpSection(header: string, ...vars: Array<OrgConfigProperties | SfdxPropertyKeys | EnvironmentVariable | string | Record<string, string>>): HelpSection;
19
19
  //# sourceMappingURL=util.d.ts.map
package/lib/util.js CHANGED
@@ -19,23 +19,28 @@ const core_1 = require("@salesforce/core");
19
19
  */
20
20
  function toHelpSection(header, ...vars) {
21
21
  const body = vars
22
- .map((v) => {
23
- const orgConfig = core_1.ORG_CONFIG_ALLOWED_PROPERTIES.find(({ key }) => {
24
- return key === v;
25
- });
26
- if (orgConfig) {
27
- return { name: orgConfig.key, description: orgConfig.description };
22
+ .flatMap((v) => {
23
+ if (typeof v === 'string') {
24
+ const orgConfig = core_1.ORG_CONFIG_ALLOWED_PROPERTIES.find(({ key }) => {
25
+ return key === v;
26
+ });
27
+ if (orgConfig) {
28
+ return { name: orgConfig.key, description: orgConfig.description };
29
+ }
30
+ const sfdxProperty = core_1.SFDX_ALLOWED_PROPERTIES.find(({ key }) => key === v);
31
+ if (sfdxProperty) {
32
+ return { name: sfdxProperty.key.valueOf(), description: sfdxProperty.description };
33
+ }
34
+ const envVar = Object.entries(core_1.SUPPORTED_ENV_VARS).find(([k]) => k === v);
35
+ if (envVar) {
36
+ const [eKey, data] = envVar;
37
+ return { name: eKey, description: data.description };
38
+ }
39
+ return undefined;
28
40
  }
29
- const sfdxProperty = core_1.SFDX_ALLOWED_PROPERTIES.find(({ key }) => key === v);
30
- if (sfdxProperty) {
31
- return { name: sfdxProperty.key.valueOf(), description: sfdxProperty.description };
41
+ else {
42
+ return Object.entries(v).map(([name, description]) => ({ name, description }));
32
43
  }
33
- const envVar = Object.entries(core_1.SUPPORTED_ENV_VARS).find(([k]) => k === v);
34
- if (envVar) {
35
- const [eKey, data] = envVar;
36
- return { name: eKey, description: data.description };
37
- }
38
- return undefined;
39
44
  })
40
45
  .filter((b) => b);
41
46
  return { header, body };
@@ -1,6 +1,6 @@
1
1
  # error.prefix
2
2
 
3
- Error:
3
+ Error%s:
4
4
 
5
5
  # warning.security
6
6
 
@@ -66,10 +66,10 @@ The value must be between %s and %s (inclusive).
66
66
 
67
67
  Warning:
68
68
 
69
- # info.prefix
70
-
71
- Info:
72
-
73
69
  # actions.tryThis
74
70
 
75
71
  Try this:
72
+
73
+ # warning.CommandInBeta
74
+
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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/sf-plugins-core",
3
- "version": "1.9.0",
3
+ "version": "1.11.1",
4
4
  "description": "Utils for writing deploy and retrieve plugins",
5
5
  "main": "lib/exported",
6
6
  "types": "lib/exported.d.ts",
@@ -32,11 +32,11 @@
32
32
  "/messages"
33
33
  ],
34
34
  "dependencies": {
35
- "@oclif/core": "^1.6.0",
36
- "@salesforce/core": "^3.7.9",
35
+ "@oclif/core": "^1.6.3",
36
+ "@salesforce/core": "^3.11.0",
37
37
  "@salesforce/kit": "^1.5.34",
38
38
  "@salesforce/ts-types": "^1.5.20",
39
- "chalk": "^2.4.2",
39
+ "chalk": "^4",
40
40
  "inquirer": "^8.2.0"
41
41
  },
42
42
  "devDependencies": {