@salesforce/sf-plugins-core 1.11.0 → 1.11.3
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 +19 -0
- package/lib/exported.d.ts +1 -1
- package/lib/exported.js +2 -1
- package/lib/flags/orgFlags.d.ts +2 -2
- package/lib/flags/orgFlags.js +15 -3
- package/lib/sfCommand.d.ts +15 -1
- package/lib/sfCommand.js +28 -14
- package/messages/messages.md +1 -5
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [1.11.3](https://github.com/salesforcecli/sf-plugins-core/compare/v1.11.2...v1.11.3) (2022-04-12)
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
- need await in order for the catch to be effective ([2805578](https://github.com/salesforcecli/sf-plugins-core/commit/28055783503177667620528b6246b252ff10cb7f))
|
|
10
|
+
|
|
11
|
+
### [1.11.2](https://github.com/salesforcecli/sf-plugins-core/compare/v1.11.1...v1.11.2) (2022-04-11)
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
- optional orgs can be undefined ([412629d](https://github.com/salesforcecli/sf-plugins-core/commit/412629de689d7d73b7c2b0673b8e9b373cc957bc))
|
|
16
|
+
- throw if input provided but no org found ([10be468](https://github.com/salesforcecli/sf-plugins-core/commit/10be468c0c3e164fed171c947dbe437b2325605c))
|
|
17
|
+
|
|
18
|
+
### [1.11.1](https://github.com/salesforcecli/sf-plugins-core/compare/v1.11.0...v1.11.1) (2022-04-07)
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
- adjust message formats ([5b62ced](https://github.com/salesforcecli/sf-plugins-core/commit/5b62cedeb522c08dcce01159a22060be72c1bf62))
|
|
23
|
+
|
|
5
24
|
## [1.11.0](https://github.com/salesforcecli/sf-plugins-core/compare/v1.10.0...v1.11.0) (2022-03-31)
|
|
6
25
|
|
|
7
26
|
### 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");
|
package/lib/flags/orgFlags.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ import { Org } from '@salesforce/core';
|
|
|
18
18
|
*/
|
|
19
19
|
export declare const optionalOrgFlag: import("@oclif/core/lib/interfaces").Definition<Org | undefined>;
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
21
|
+
* A required org, specified by username or alias
|
|
22
22
|
* Will throw if the specified org default do not exist
|
|
23
23
|
* Will default to the default org if one is not specified.
|
|
24
24
|
* Will throw if no default org exists and none is specified
|
|
@@ -38,7 +38,7 @@ export declare const optionalOrgFlag: import("@oclif/core/lib/interfaces").Defin
|
|
|
38
38
|
*/
|
|
39
39
|
export declare const requiredOrgFlag: import("@oclif/core/lib/interfaces").Definition<Org>;
|
|
40
40
|
/**
|
|
41
|
-
*
|
|
41
|
+
* A required org that is a devHub
|
|
42
42
|
* Will throw if the specified org does not exist
|
|
43
43
|
* Will default to the default dev hub if one is not specified
|
|
44
44
|
* Will throw if no default deb hub exists and none is specified
|
package/lib/flags/orgFlags.js
CHANGED
|
@@ -11,7 +11,19 @@ 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
|
-
const maybeGetOrg = async (input) =>
|
|
14
|
+
const maybeGetOrg = async (input) => {
|
|
15
|
+
try {
|
|
16
|
+
return await core_2.Org.create({ aliasOrUsername: input });
|
|
17
|
+
}
|
|
18
|
+
catch (e) {
|
|
19
|
+
if (!input) {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
throw e;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
15
27
|
const getOrgOrThrow = async (input) => {
|
|
16
28
|
const org = await maybeGetOrg(input);
|
|
17
29
|
if (!org) {
|
|
@@ -60,7 +72,7 @@ exports.optionalOrgFlag = core_1.Flags.build({
|
|
|
60
72
|
defaultHelp: async () => { var _a; return (_a = (await maybeGetOrg())) === null || _a === void 0 ? void 0 : _a.getUsername(); },
|
|
61
73
|
});
|
|
62
74
|
/**
|
|
63
|
-
*
|
|
75
|
+
* A required org, specified by username or alias
|
|
64
76
|
* Will throw if the specified org default do not exist
|
|
65
77
|
* Will default to the default org if one is not specified.
|
|
66
78
|
* Will throw if no default org exists and none is specified
|
|
@@ -85,7 +97,7 @@ exports.requiredOrgFlag = core_1.Flags.build({
|
|
|
85
97
|
defaultHelp: async () => { var _a; return (_a = (await getOrgOrThrow())) === null || _a === void 0 ? void 0 : _a.getUsername(); },
|
|
86
98
|
});
|
|
87
99
|
/**
|
|
88
|
-
*
|
|
100
|
+
* A required org that is a devHub
|
|
89
101
|
* Will throw if the specified org does not exist
|
|
90
102
|
* Will default to the default dev hub if one is not specified
|
|
91
103
|
* Will throw if no default deb hub exists and none is specified
|
package/lib/sfCommand.d.ts
CHANGED
|
@@ -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
|
|
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(`${
|
|
48
|
-
colorizedArgs.push(...this.formatActions(typeof input === 'string' ? [] : input.actions || [], { actionColor:
|
|
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(`${
|
|
59
|
-
colorizedArgs.push(...this.formatActions(typeof input === 'string' ? [] : input.actions || [], { actionColor:
|
|
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
|
-
|
|
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(
|
|
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:
|
|
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${
|
|
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
|
});
|
package/messages/messages.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/sf-plugins-core",
|
|
3
|
-
"version": "1.11.
|
|
3
|
+
"version": "1.11.3",
|
|
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": "^
|
|
39
|
+
"chalk": "^4",
|
|
40
40
|
"inquirer": "^8.2.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|