@salesforce/sf-plugins-core 1.11.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,12 @@
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
+
5
11
  ## [1.11.0](https://github.com/salesforcecli/sf-plugins-core/compare/v1.10.0...v1.11.0) (2022-03-31)
6
12
 
7
13
  ### 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
  /**
@@ -196,7 +211,7 @@ class SfCommand extends core_1.Command {
196
211
  return error;
197
212
  }
198
213
  /**
199
- * Format errors and actions for human consumption. Adds 'Error:',
214
+ * Format errors and actions for human consumption. Adds 'Error (<ErrorCode>):',
200
215
  * When there are actions, we add 'Try this:' in blue
201
216
  * followed by each action in red on its own line.
202
217
  * If Error.code is present it is output last in parentheses
@@ -205,13 +220,12 @@ class SfCommand extends core_1.Command {
205
220
  */
206
221
  formatError(error) {
207
222
  const colorizedArgs = [];
208
- 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}`);
209
226
  colorizedArgs.push(...this.formatActions(error.actions || []));
210
227
  if (error.stack && core_2.envVars.getString(SfCommand.SF_ENV) === core_2.Mode.DEVELOPMENT) {
211
- colorizedArgs.push(chalk_1.default.red(`\n*** Internal Diagnostic ***\n\n${error.stack}\n******\n`));
212
- }
213
- if (error.code) {
214
- colorizedArgs.push(chalk_1.default.bold(`\n(${error.code})`));
228
+ colorizedArgs.push(exports.StandardColors.info(`\n*** Internal Diagnostic ***\n\n${error.stack}\n******\n`));
215
229
  }
216
230
  return colorizedArgs.join('\n');
217
231
  }
@@ -222,11 +236,11 @@ class SfCommand extends core_1.Command {
222
236
  * @param options
223
237
  * @private
224
238
  */
225
- formatActions(actions, options = { actionColor: chalk_1.default.red }) {
239
+ formatActions(actions, options = { actionColor: exports.StandardColors.info }) {
226
240
  const colorizedArgs = [];
227
241
  // Format any actions.
228
242
  if (actions === null || actions === void 0 ? void 0 : actions.length) {
229
- 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`);
230
244
  actions.forEach((action) => {
231
245
  colorizedArgs.push(`${options.actionColor(action)}`);
232
246
  });
@@ -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,6 @@ 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:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/sf-plugins-core",
3
- "version": "1.11.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",
@@ -36,7 +36,7 @@
36
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": {