@salesforce/sf-plugins-core 5.0.13 → 5.0.14-dev.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/LICENSE.txt +1 -1
- package/README.md +2 -5
- package/lib/compatibility.d.ts +7 -7
- package/lib/compatibility.js +14 -17
- package/lib/errorFormatting.d.ts +22 -0
- package/lib/errorFormatting.js +41 -0
- package/lib/exported.d.ts +9 -70
- package/lib/exported.js +9 -62
- package/lib/flags/duration.d.ts +1 -1
- package/lib/flags/duration.js +7 -10
- package/lib/flags/flags.d.ts +63 -0
- package/lib/flags/flags.js +30 -0
- package/lib/flags/orgApiVersion.d.ts +1 -1
- package/lib/flags/orgApiVersion.js +16 -19
- package/lib/flags/orgFlags.d.ts +4 -4
- package/lib/flags/orgFlags.js +30 -37
- package/lib/flags/salesforceId.d.ts +1 -1
- package/lib/flags/salesforceId.js +6 -9
- package/lib/prompts.d.ts +13 -0
- package/lib/prompts.js +25 -0
- package/lib/sfCommand.d.ts +26 -94
- package/lib/sfCommand.js +130 -131
- package/lib/sfCommandNamespace.d.ts +24 -0
- package/lib/sfCommandNamespace.js +2 -0
- package/lib/stubUx.d.ts +7 -9
- package/lib/stubUx.js +30 -37
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/util.d.ts +1 -0
- package/lib/util.js +9 -13
- package/lib/ux/base.d.ts +1 -1
- package/lib/ux/base.js +2 -5
- package/lib/ux/progress.d.ts +1 -1
- package/lib/ux/progress.js +15 -17
- package/lib/ux/spinner.d.ts +1 -1
- package/lib/ux/spinner.js +8 -12
- package/lib/ux/standardColors.d.ts +7 -0
- package/lib/ux/standardColors.js +14 -0
- package/lib/ux/ux.d.ts +2 -4
- package/lib/ux/ux.js +14 -18
- package/package.json +17 -11
- package/lib/deauthorizer.d.ts +0 -22
- package/lib/deauthorizer.js +0 -35
- package/lib/deployer.d.ts +0 -81
- package/lib/deployer.js +0 -58
- package/lib/hooks.d.ts +0 -34
- package/lib/hooks.js +0 -30
- package/lib/types/index.d.ts +0 -128
- package/lib/types/index.js +0 -55
- package/lib/ux/index.d.ts +0 -6
- package/lib/ux/index.js +0 -22
- package/lib/ux/prompter.d.ts +0 -40
- package/lib/ux/prompter.js +0 -99
package/lib/flags/orgFlags.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ export declare const getHubOrThrow: (aliasOrUsername?: string) => Promise<Org>;
|
|
|
25
25
|
* }
|
|
26
26
|
* ```
|
|
27
27
|
*/
|
|
28
|
-
export declare const optionalOrgFlag: import("@oclif/core/lib/interfaces").FlagDefinition<Org, import("@oclif/core/lib/interfaces").CustomOptions, {
|
|
28
|
+
export declare const optionalOrgFlag: import("@oclif/core/lib/interfaces/parser.js").FlagDefinition<Org, import("@oclif/core/lib/interfaces/parser.js").CustomOptions, {
|
|
29
29
|
multiple: false;
|
|
30
30
|
requiredOrDefaulted: true;
|
|
31
31
|
}>;
|
|
@@ -51,7 +51,7 @@ export declare const optionalOrgFlag: import("@oclif/core/lib/interfaces").FlagD
|
|
|
51
51
|
* }
|
|
52
52
|
* ```
|
|
53
53
|
*/
|
|
54
|
-
export declare const requiredOrgFlag: import("@oclif/core/lib/interfaces").FlagDefinition<Org, import("@oclif/core/lib/interfaces").CustomOptions, {
|
|
54
|
+
export declare const requiredOrgFlag: import("@oclif/core/lib/interfaces/parser.js").FlagDefinition<Org, import("@oclif/core/lib/interfaces/parser.js").CustomOptions, {
|
|
55
55
|
multiple: false;
|
|
56
56
|
requiredOrDefaulted: true;
|
|
57
57
|
}>;
|
|
@@ -77,7 +77,7 @@ export declare const requiredOrgFlag: import("@oclif/core/lib/interfaces").FlagD
|
|
|
77
77
|
* }
|
|
78
78
|
* ```
|
|
79
79
|
*/
|
|
80
|
-
export declare const requiredHubFlag: import("@oclif/core/lib/interfaces").FlagDefinition<Org, import("@oclif/core/lib/interfaces").CustomOptions, {
|
|
80
|
+
export declare const requiredHubFlag: import("@oclif/core/lib/interfaces/parser.js").FlagDefinition<Org, import("@oclif/core/lib/interfaces/parser.js").CustomOptions, {
|
|
81
81
|
multiple: false;
|
|
82
82
|
requiredOrDefaulted: true;
|
|
83
83
|
}>;
|
|
@@ -102,7 +102,7 @@ export declare const requiredHubFlag: import("@oclif/core/lib/interfaces").FlagD
|
|
|
102
102
|
* }
|
|
103
103
|
* ```
|
|
104
104
|
*/
|
|
105
|
-
export declare const optionalHubFlag: import("@oclif/core/lib/interfaces").FlagDefinition<Org, import("@oclif/core/lib/interfaces").CustomOptions, {
|
|
105
|
+
export declare const optionalHubFlag: import("@oclif/core/lib/interfaces/parser.js").FlagDefinition<Org, import("@oclif/core/lib/interfaces/parser.js").CustomOptions, {
|
|
106
106
|
multiple: false;
|
|
107
107
|
requiredOrDefaulted: true;
|
|
108
108
|
}>;
|
package/lib/flags/orgFlags.js
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.optionalHubFlag = exports.requiredHubFlag = exports.requiredOrgFlag = exports.optionalOrgFlag = exports.getHubOrThrow = exports.getOrgOrThrow = exports.maybeGetHub = exports.maybeGetOrg = void 0;
|
|
4
1
|
/*
|
|
5
2
|
* Copyright (c) 2020, salesforce.com, inc.
|
|
6
3
|
* All rights reserved.
|
|
7
4
|
* Licensed under the BSD 3-Clause license.
|
|
8
5
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
9
6
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const messages =
|
|
14
|
-
async function maybeGetOrg(input) {
|
|
7
|
+
import { Flags } from '@oclif/core';
|
|
8
|
+
import { ConfigAggregator, Messages, Org, OrgConfigProperties } from '@salesforce/core';
|
|
9
|
+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
10
|
+
const messages = Messages.loadMessages('@salesforce/sf-plugins-core', 'messages');
|
|
11
|
+
export async function maybeGetOrg(input) {
|
|
15
12
|
try {
|
|
16
|
-
return await
|
|
13
|
+
return await Org.create({ aliasOrUsername: input });
|
|
17
14
|
}
|
|
18
15
|
catch (e) {
|
|
19
16
|
if (!input) {
|
|
@@ -24,19 +21,18 @@ async function maybeGetOrg(input) {
|
|
|
24
21
|
}
|
|
25
22
|
}
|
|
26
23
|
}
|
|
27
|
-
|
|
28
|
-
const maybeGetHub = async (input) => {
|
|
24
|
+
export const maybeGetHub = async (input) => {
|
|
29
25
|
let org;
|
|
30
26
|
// user provided input, verify the org exits
|
|
31
27
|
if (input) {
|
|
32
|
-
org = await
|
|
28
|
+
org = await getOrgOrThrow(input);
|
|
33
29
|
}
|
|
34
30
|
else {
|
|
35
31
|
// no input, check config for a default
|
|
36
32
|
const aliasOrUsername = await getDefaultHub(false);
|
|
37
33
|
// if there is a default, verify the org exists
|
|
38
34
|
if (aliasOrUsername) {
|
|
39
|
-
org = await
|
|
35
|
+
org = await getOrgOrThrow(aliasOrUsername);
|
|
40
36
|
}
|
|
41
37
|
}
|
|
42
38
|
if (org) {
|
|
@@ -46,15 +42,13 @@ const maybeGetHub = async (input) => {
|
|
|
46
42
|
return undefined;
|
|
47
43
|
}
|
|
48
44
|
};
|
|
49
|
-
|
|
50
|
-
const getOrgOrThrow = async (input) => {
|
|
45
|
+
export const getOrgOrThrow = async (input) => {
|
|
51
46
|
const org = await maybeGetOrg(input);
|
|
52
47
|
if (!org) {
|
|
53
48
|
throw messages.createError('errors.NoDefaultEnv');
|
|
54
49
|
}
|
|
55
50
|
return org;
|
|
56
51
|
};
|
|
57
|
-
exports.getOrgOrThrow = getOrgOrThrow;
|
|
58
52
|
const ensureDevHub = async (org, aliasOrUsername) => {
|
|
59
53
|
if (await org.determineIfDevHubOrg()) {
|
|
60
54
|
return org;
|
|
@@ -63,19 +57,18 @@ const ensureDevHub = async (org, aliasOrUsername) => {
|
|
|
63
57
|
};
|
|
64
58
|
async function getDefaultHub(throwIfNotFound) {
|
|
65
59
|
// check config for a default
|
|
66
|
-
const config = await
|
|
67
|
-
const aliasOrUsername = config.getInfo(
|
|
60
|
+
const config = await ConfigAggregator.create();
|
|
61
|
+
const aliasOrUsername = config.getInfo(OrgConfigProperties.TARGET_DEV_HUB)?.value;
|
|
68
62
|
if (throwIfNotFound && !aliasOrUsername) {
|
|
69
63
|
throw messages.createError('errors.NoDefaultDevHub');
|
|
70
64
|
}
|
|
71
65
|
return aliasOrUsername;
|
|
72
66
|
}
|
|
73
|
-
const getHubOrThrow = async (aliasOrUsername) => {
|
|
67
|
+
export const getHubOrThrow = async (aliasOrUsername) => {
|
|
74
68
|
const resolved = aliasOrUsername ?? (await getDefaultHub(true));
|
|
75
|
-
const org = await
|
|
69
|
+
const org = await Org.create({ aliasOrUsername: resolved, isDevHub: true });
|
|
76
70
|
return ensureDevHub(org, resolved);
|
|
77
71
|
};
|
|
78
|
-
exports.getHubOrThrow = getHubOrThrow;
|
|
79
72
|
/**
|
|
80
73
|
* An optional org specified by username or alias
|
|
81
74
|
* Will default to the default org if one is not specified.
|
|
@@ -96,13 +89,13 @@ exports.getHubOrThrow = getHubOrThrow;
|
|
|
96
89
|
* }
|
|
97
90
|
* ```
|
|
98
91
|
*/
|
|
99
|
-
|
|
92
|
+
export const optionalOrgFlag = Flags.custom({
|
|
100
93
|
char: 'o',
|
|
101
94
|
noCacheDefault: true,
|
|
102
95
|
parse: async (input) => maybeGetOrg(input),
|
|
103
96
|
default: async () => maybeGetOrg(),
|
|
104
97
|
defaultHelp: async (context) => {
|
|
105
|
-
if (context.options instanceof
|
|
98
|
+
if (context.options instanceof Org) {
|
|
106
99
|
const org = context.options;
|
|
107
100
|
return org.getUsername();
|
|
108
101
|
}
|
|
@@ -131,14 +124,14 @@ exports.optionalOrgFlag = core_1.Flags.custom({
|
|
|
131
124
|
* }
|
|
132
125
|
* ```
|
|
133
126
|
*/
|
|
134
|
-
|
|
127
|
+
export const requiredOrgFlag = Flags.custom({
|
|
135
128
|
char: 'o',
|
|
136
129
|
summary: messages.getMessage('flags.targetOrg.summary'),
|
|
137
130
|
noCacheDefault: true,
|
|
138
|
-
parse: async (input) =>
|
|
139
|
-
default: async () =>
|
|
131
|
+
parse: async (input) => getOrgOrThrow(input),
|
|
132
|
+
default: async () => getOrgOrThrow(),
|
|
140
133
|
defaultHelp: async (context) => {
|
|
141
|
-
if (context.options instanceof
|
|
134
|
+
if (context.options instanceof Org) {
|
|
142
135
|
const org = context.options;
|
|
143
136
|
return org.getUsername();
|
|
144
137
|
}
|
|
@@ -168,18 +161,18 @@ exports.requiredOrgFlag = core_1.Flags.custom({
|
|
|
168
161
|
* }
|
|
169
162
|
* ```
|
|
170
163
|
*/
|
|
171
|
-
|
|
164
|
+
export const requiredHubFlag = Flags.custom({
|
|
172
165
|
char: 'v',
|
|
173
166
|
summary: messages.getMessage('flags.targetDevHubOrg.summary'),
|
|
174
167
|
noCacheDefault: true,
|
|
175
|
-
parse: async (input) =>
|
|
176
|
-
default: async () =>
|
|
168
|
+
parse: async (input) => getHubOrThrow(input),
|
|
169
|
+
default: async () => getHubOrThrow(),
|
|
177
170
|
defaultHelp: async (context) => {
|
|
178
|
-
if (context.options instanceof
|
|
171
|
+
if (context.options instanceof Org) {
|
|
179
172
|
const org = context.options;
|
|
180
173
|
return org.getUsername();
|
|
181
174
|
}
|
|
182
|
-
return (await
|
|
175
|
+
return (await maybeGetHub())?.getUsername();
|
|
183
176
|
},
|
|
184
177
|
required: true,
|
|
185
178
|
});
|
|
@@ -204,18 +197,18 @@ exports.requiredHubFlag = core_1.Flags.custom({
|
|
|
204
197
|
* }
|
|
205
198
|
* ```
|
|
206
199
|
*/
|
|
207
|
-
|
|
200
|
+
export const optionalHubFlag = Flags.custom({
|
|
208
201
|
char: 'v',
|
|
209
202
|
summary: messages.getMessage('flags.targetDevHubOrg.summary'),
|
|
210
203
|
noCacheDefault: true,
|
|
211
|
-
parse: async (input) =>
|
|
212
|
-
default: async () =>
|
|
204
|
+
parse: async (input) => maybeGetHub(input),
|
|
205
|
+
default: async () => maybeGetHub(),
|
|
213
206
|
defaultHelp: async (context) => {
|
|
214
|
-
if (context.options instanceof
|
|
207
|
+
if (context.options instanceof Org) {
|
|
215
208
|
const org = context.options;
|
|
216
209
|
return org.getUsername();
|
|
217
210
|
}
|
|
218
|
-
return (await
|
|
211
|
+
return (await maybeGetHub())?.getUsername();
|
|
219
212
|
},
|
|
220
213
|
required: false,
|
|
221
214
|
});
|
|
@@ -30,7 +30,7 @@ export type IdFlagConfig = {
|
|
|
30
30
|
* }
|
|
31
31
|
* ```
|
|
32
32
|
*/
|
|
33
|
-
export declare const salesforceIdFlag: import("@oclif/core/lib/interfaces").FlagDefinition<string, IdFlagConfig, {
|
|
33
|
+
export declare const salesforceIdFlag: import("@oclif/core/lib/interfaces/parser.js").FlagDefinition<string, IdFlagConfig, {
|
|
34
34
|
multiple: false;
|
|
35
35
|
requiredOrDefaulted: false;
|
|
36
36
|
}>;
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.salesforceIdFlag = void 0;
|
|
4
1
|
/*
|
|
5
2
|
* Copyright (c) 2020, salesforce.com, inc.
|
|
6
3
|
* All rights reserved.
|
|
7
4
|
* Licensed under the BSD 3-Clause license.
|
|
8
5
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
9
6
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const messages =
|
|
7
|
+
import { Flags } from '@oclif/core';
|
|
8
|
+
import { Messages, validateSalesforceId } from '@salesforce/core';
|
|
9
|
+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
10
|
+
const messages = Messages.loadMessages('@salesforce/sf-plugins-core', 'messages');
|
|
14
11
|
/**
|
|
15
12
|
* Id flag with built-in validation. Short character is `i`
|
|
16
13
|
*
|
|
@@ -33,7 +30,7 @@ const messages = core_2.Messages.loadMessages('@salesforce/sf-plugins-core', 'me
|
|
|
33
30
|
* }
|
|
34
31
|
* ```
|
|
35
32
|
*/
|
|
36
|
-
|
|
33
|
+
export const salesforceIdFlag = Flags.custom({
|
|
37
34
|
// eslint-disable-next-line @typescript-eslint/require-await
|
|
38
35
|
parse: async (input, _ctx, opts) => validate(input, opts),
|
|
39
36
|
char: 'i',
|
|
@@ -47,7 +44,7 @@ const validate = (input, config) => {
|
|
|
47
44
|
allowedIdLength.join(` ${messages.getMessage('errors.InvalidIdLength.or')} `),
|
|
48
45
|
]);
|
|
49
46
|
}
|
|
50
|
-
if (!
|
|
47
|
+
if (!validateSalesforceId(input)) {
|
|
51
48
|
throw messages.createError('errors.InvalidId');
|
|
52
49
|
}
|
|
53
50
|
if (startsWith && !input.startsWith(startsWith)) {
|
package/lib/prompts.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type PromptInputs<T> = {
|
|
2
|
+
/** text to display. Do not include a question mark */
|
|
3
|
+
message: string;
|
|
4
|
+
/** after this many ms, the prompt will time out. If a default value is provided, the default will be used. Otherwise the prompt will throw an error */
|
|
5
|
+
ms?: number;
|
|
6
|
+
/**
|
|
7
|
+
* default value to offer to the user. Will be used if the user does not respond within the timeout period.
|
|
8
|
+
*/
|
|
9
|
+
defaultAnswer?: T;
|
|
10
|
+
};
|
|
11
|
+
export declare const confirm: ({ message, ms, defaultAnswer, }: PromptInputs<boolean>) => Promise<boolean>;
|
|
12
|
+
export declare const secretPrompt: ({ message, ms }: PromptInputs<string>) => Promise<string>;
|
|
13
|
+
//# sourceMappingURL=prompts.d.ts.map
|
package/lib/prompts.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023, salesforce.com, inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* Licensed under the BSD 3-Clause license.
|
|
5
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
*/
|
|
7
|
+
import { setTimeout } from 'node:timers/promises';
|
|
8
|
+
import { SfError } from '@salesforce/core';
|
|
9
|
+
export const confirm = async ({ message, ms = 10000, defaultAnswer = false, }) => {
|
|
10
|
+
const promptConfirm = (await import('@inquirer/confirm')).default;
|
|
11
|
+
const answer = promptConfirm({ message, default: defaultAnswer });
|
|
12
|
+
return Promise.race([answer, handleTimeout(answer, ms, defaultAnswer)]);
|
|
13
|
+
};
|
|
14
|
+
export const secretPrompt = async ({ message, ms = 60000 }) => {
|
|
15
|
+
const promptSecret = (await import('@inquirer/password')).default;
|
|
16
|
+
const answer = promptSecret({ message });
|
|
17
|
+
return Promise.race([answer, handleTimeout(answer, ms)]);
|
|
18
|
+
};
|
|
19
|
+
const handleTimeout = async (answer, ms, defaultAnswer) => setTimeout(ms, undefined, { ref: false }).then(() => {
|
|
20
|
+
answer.cancel();
|
|
21
|
+
if (typeof defaultAnswer !== 'undefined')
|
|
22
|
+
return defaultAnswer;
|
|
23
|
+
throw new SfError('Prompt timed out.');
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=prompts.js.map
|
package/lib/sfCommand.d.ts
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { SfProject,
|
|
3
|
-
import { AnyJson } from '@salesforce/ts-types';
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
1
|
+
import { Command, Config, HelpSection } from '@oclif/core';
|
|
2
|
+
import { SfProject, SfError, ConfigAggregator } from '@salesforce/core';
|
|
3
|
+
import type { AnyJson } from '@salesforce/ts-types';
|
|
4
|
+
import { Progress } from './ux/progress.js';
|
|
5
|
+
import { Spinner } from './ux/spinner.js';
|
|
6
|
+
import { Ux } from './ux/ux.js';
|
|
7
|
+
import { SfCommand as ns } from './sfCommandNamespace.js';
|
|
8
|
+
import { PromptInputs } from './prompts.js';
|
|
6
9
|
export interface SfCommandInterface extends Command.Class {
|
|
7
10
|
configurationVariablesSection?: HelpSection;
|
|
8
11
|
envVariablesSection?: HelpSection;
|
|
9
12
|
errorCodes?: HelpSection;
|
|
10
13
|
}
|
|
11
|
-
export declare const StandardColors: {
|
|
12
|
-
error: chalk.Chalk;
|
|
13
|
-
warning: chalk.Chalk;
|
|
14
|
-
info: chalk.Chalk;
|
|
15
|
-
success: chalk.Chalk;
|
|
16
|
-
};
|
|
17
14
|
/**
|
|
18
15
|
* A base command that provided common functionality for all sf commands.
|
|
19
16
|
* Functionality includes:
|
|
@@ -46,7 +43,6 @@ export declare const StandardColors: {
|
|
|
46
43
|
* ```
|
|
47
44
|
*/
|
|
48
45
|
export declare abstract class SfCommand<T> extends Command {
|
|
49
|
-
static SF_ENV: string;
|
|
50
46
|
static enableJsonFlag: boolean;
|
|
51
47
|
/**
|
|
52
48
|
* Add a CONFIGURATION VARIABLES section to the help output.
|
|
@@ -97,21 +93,6 @@ export declare abstract class SfCommand<T> extends Command {
|
|
|
97
93
|
* ```
|
|
98
94
|
*/
|
|
99
95
|
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
|
-
*/
|
|
114
|
-
static tableFlags: typeof ux.Table.table.flags;
|
|
115
96
|
/**
|
|
116
97
|
* Set to true if the command must be executed inside a Salesforce project directory.
|
|
117
98
|
*
|
|
@@ -128,14 +109,13 @@ export declare abstract class SfCommand<T> extends Command {
|
|
|
128
109
|
* Add a progress bar to the console. {@link Progress}
|
|
129
110
|
*/
|
|
130
111
|
progress: Progress;
|
|
131
|
-
project
|
|
112
|
+
project?: SfProject;
|
|
132
113
|
/**
|
|
133
114
|
* ConfigAggregator instance for accessing global and local configuration.
|
|
134
115
|
*/
|
|
135
116
|
configAggregator: ConfigAggregator;
|
|
136
117
|
private warnings;
|
|
137
118
|
private ux;
|
|
138
|
-
private prompter;
|
|
139
119
|
private lifecycle;
|
|
140
120
|
constructor(argv: string[], config: Config);
|
|
141
121
|
protected get statics(): typeof SfCommand;
|
|
@@ -151,13 +131,13 @@ export declare abstract class SfCommand<T> extends Command {
|
|
|
151
131
|
*
|
|
152
132
|
* @param input {@link SfCommand.Warning} The message to log.
|
|
153
133
|
*/
|
|
154
|
-
warn(input:
|
|
134
|
+
warn(input: ns.Warning): ns.Warning;
|
|
155
135
|
/**
|
|
156
136
|
* Log info message to users.
|
|
157
137
|
*
|
|
158
138
|
* @param input {@link SfCommand.Info} The message to log.
|
|
159
139
|
*/
|
|
160
|
-
info(input:
|
|
140
|
+
info(input: ns.Info): void;
|
|
161
141
|
/**
|
|
162
142
|
* Warn user about sensitive information (access tokens, etc...) before logging to the console.
|
|
163
143
|
*
|
|
@@ -195,82 +175,34 @@ export declare abstract class SfCommand<T> extends Command {
|
|
|
195
175
|
styledHeader(text: string): void;
|
|
196
176
|
logJson(json: AnyJson | unknown): void;
|
|
197
177
|
/**
|
|
198
|
-
* Prompt user for
|
|
199
|
-
*
|
|
200
|
-
* This will NOT be automatically suppressed when the --json flag is present since we assume
|
|
201
|
-
* that any command that prompts the user for required information will not also support the --json flag.
|
|
178
|
+
* Prompt user for yes/no confirmation.
|
|
179
|
+
* Avoid calling in --json scenarios and always provide a `--no-prompt` option for scripting
|
|
202
180
|
*
|
|
203
|
-
*
|
|
181
|
+
* @param message text to display. Do not include a question mark.
|
|
182
|
+
* @param ms milliseconds to wait for user input. Defaults to 60s. Will throw an error when timeout is reached.
|
|
204
183
|
*
|
|
205
|
-
* @example
|
|
206
|
-
* if (!this.jsonEnabled()) {
|
|
207
|
-
* await this.prompt();
|
|
208
|
-
* }
|
|
209
184
|
*/
|
|
210
|
-
|
|
185
|
+
secretPrompt({ message, ms }: PromptInputs<string>): Promise<string>;
|
|
211
186
|
/**
|
|
212
|
-
*
|
|
187
|
+
* Prompt user for yes/no confirmation.
|
|
188
|
+
* Avoid calling in --json scenarios and always provide a `--no-prompt` option for scripting
|
|
189
|
+
*
|
|
190
|
+
* @param message text to display. Do not include a question mark or Y/N.
|
|
191
|
+
* @param ms milliseconds to wait for user input. Defaults to 10s. Will use the default value when timeout is reached.
|
|
192
|
+
* @param defaultAnswer boolean to set the default answer to. Defaults to false.
|
|
213
193
|
*
|
|
214
|
-
* @param message text to display. Do not include a question mark.
|
|
215
|
-
* @param ms milliseconds to wait for user input. Defaults to 10s.
|
|
216
|
-
* @param defaultAnswer boolean to set the default answer to. Defaults to true.
|
|
217
|
-
* @return true if the user confirms, false if they do not.
|
|
218
|
-
*/
|
|
219
|
-
confirm(message: string, ms?: number, defaultAnswer?: boolean): Promise<boolean>;
|
|
220
|
-
/**
|
|
221
|
-
* Prompt user for information with a timeout (in milliseconds). See https://www.npmjs.com/package/inquirer for more.
|
|
222
194
|
*/
|
|
223
|
-
|
|
195
|
+
confirm({ message, ms, defaultAnswer }: PromptInputs<boolean>): Promise<boolean>;
|
|
224
196
|
_run<R>(): Promise<R>;
|
|
225
197
|
/**
|
|
226
198
|
* Wrap the command result into the standardized JSON structure.
|
|
227
199
|
*/
|
|
228
|
-
protected toSuccessJson(result: T):
|
|
200
|
+
protected toSuccessJson(result: T): ns.Json<T>;
|
|
229
201
|
/**
|
|
230
202
|
* Wrap the command error into the standardized JSON structure.
|
|
231
203
|
*/
|
|
232
|
-
protected toErrorJson(error:
|
|
233
|
-
protected
|
|
234
|
-
protected catch(error: Error | SfError | SfCommand.Error): Promise<SfCommand.Error>;
|
|
235
|
-
/**
|
|
236
|
-
* Format errors and actions for human consumption. Adds 'Error (<ErrorCode>):',
|
|
237
|
-
* When there are actions, we add 'Try this:' in blue
|
|
238
|
-
* followed by each action in red on its own line.
|
|
239
|
-
* If Error.code is present it is output last in parentheses
|
|
240
|
-
*
|
|
241
|
-
* @returns {string} Returns decorated messages.
|
|
242
|
-
*/
|
|
243
|
-
protected formatError(error: SfCommand.Error): string;
|
|
244
|
-
/**
|
|
245
|
-
* Utility function to format actions lines
|
|
246
|
-
*
|
|
247
|
-
* @param actions
|
|
248
|
-
* @param options
|
|
249
|
-
* @private
|
|
250
|
-
*/
|
|
251
|
-
private formatActions;
|
|
204
|
+
protected toErrorJson(error: ns.Error): ns.Error;
|
|
205
|
+
protected catch(error: Error | SfError | ns.Error): Promise<never>;
|
|
252
206
|
abstract run(): Promise<T>;
|
|
253
207
|
}
|
|
254
|
-
export declare namespace SfCommand {
|
|
255
|
-
type Info = StructuredMessage | string;
|
|
256
|
-
type Warning = StructuredMessage | string;
|
|
257
|
-
interface Json<T> {
|
|
258
|
-
status: number;
|
|
259
|
-
result: T;
|
|
260
|
-
warnings?: Warning[];
|
|
261
|
-
}
|
|
262
|
-
interface Error {
|
|
263
|
-
status: number;
|
|
264
|
-
name: string;
|
|
265
|
-
message: string;
|
|
266
|
-
stack: string | undefined;
|
|
267
|
-
warnings?: Warning[];
|
|
268
|
-
actions?: string[];
|
|
269
|
-
code?: unknown;
|
|
270
|
-
exitCode?: number;
|
|
271
|
-
data?: unknown;
|
|
272
|
-
context?: string;
|
|
273
|
-
commandName?: string;
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
208
|
//# sourceMappingURL=sfCommand.d.ts.map
|