@salesforce/sf-plugins-core 5.0.13 → 5.0.14-dev.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.
Files changed (52) hide show
  1. package/LICENSE.txt +1 -1
  2. package/README.md +2 -5
  3. package/lib/compatibility.d.ts +7 -7
  4. package/lib/compatibility.js +14 -17
  5. package/lib/errorFormatting.d.ts +22 -0
  6. package/lib/errorFormatting.js +41 -0
  7. package/lib/exported.d.ts +10 -70
  8. package/lib/exported.js +10 -62
  9. package/lib/flags/duration.d.ts +1 -1
  10. package/lib/flags/duration.js +7 -10
  11. package/lib/flags/flags.d.ts +63 -0
  12. package/lib/flags/flags.js +30 -0
  13. package/lib/flags/orgApiVersion.d.ts +1 -1
  14. package/lib/flags/orgApiVersion.js +16 -19
  15. package/lib/flags/orgFlags.d.ts +4 -4
  16. package/lib/flags/orgFlags.js +30 -37
  17. package/lib/flags/salesforceId.d.ts +1 -1
  18. package/lib/flags/salesforceId.js +6 -9
  19. package/lib/sfCommand.d.ts +26 -94
  20. package/lib/sfCommand.js +130 -131
  21. package/lib/sfCommandNamespace.d.ts +24 -0
  22. package/lib/sfCommandNamespace.js +2 -0
  23. package/lib/stubUx.d.ts +7 -9
  24. package/lib/stubUx.js +30 -37
  25. package/lib/tsconfig.tsbuildinfo +1 -1
  26. package/lib/util.d.ts +1 -0
  27. package/lib/util.js +9 -13
  28. package/lib/ux/base.d.ts +1 -1
  29. package/lib/ux/base.js +2 -5
  30. package/lib/ux/progress.d.ts +1 -1
  31. package/lib/ux/progress.js +15 -17
  32. package/lib/ux/prompts.d.ts +17 -0
  33. package/lib/ux/prompts.js +26 -0
  34. package/lib/ux/spinner.d.ts +1 -1
  35. package/lib/ux/spinner.js +8 -12
  36. package/lib/ux/standardColors.d.ts +7 -0
  37. package/lib/ux/standardColors.js +14 -0
  38. package/lib/ux/ux.d.ts +2 -4
  39. package/lib/ux/ux.js +14 -18
  40. package/package.json +17 -11
  41. package/lib/deauthorizer.d.ts +0 -22
  42. package/lib/deauthorizer.js +0 -35
  43. package/lib/deployer.d.ts +0 -81
  44. package/lib/deployer.js +0 -58
  45. package/lib/hooks.d.ts +0 -34
  46. package/lib/hooks.js +0 -30
  47. package/lib/types/index.d.ts +0 -128
  48. package/lib/types/index.js +0 -55
  49. package/lib/ux/index.d.ts +0 -6
  50. package/lib/ux/index.js +0 -22
  51. package/lib/ux/prompter.d.ts +0 -40
  52. package/lib/ux/prompter.js +0 -99
package/lib/deployer.js DELETED
@@ -1,58 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2022, salesforce.com, inc.
4
- * All rights reserved.
5
- * Licensed under the BSD 3-Clause license.
6
- * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
7
- */
8
- /* eslint-disable @typescript-eslint/explicit-member-accessibility */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.Deployer = exports.Deployable = void 0;
11
- const node_events_1 = require("node:events");
12
- const core_1 = require("@oclif/core");
13
- const ux_1 = require("./ux");
14
- class Deployable {
15
- }
16
- exports.Deployable = Deployable;
17
- /**
18
- * Interface for deploying Deployables.
19
- */
20
- class Deployer extends node_events_1.EventEmitter {
21
- constructor() {
22
- super(...arguments);
23
- /**
24
- * Deployables are individual pieces that can be deployed on their own. For example,
25
- * each package in a salesforce project is considered a deployable that can be deployed
26
- * on its own.
27
- */
28
- this.deployables = [];
29
- this.prompter = new ux_1.Prompter();
30
- }
31
- /**
32
- * Method for displaying deploy progress to the user
33
- */
34
- // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function, class-methods-use-this
35
- progress(current, total, message) { }
36
- /**
37
- * Log messages to the console
38
- */
39
- // eslint-disable-next-line class-methods-use-this
40
- log(msg, ...args) {
41
- core_1.ux.log(msg, ...args);
42
- }
43
- /**
44
- * Prompt user for additional information
45
- */
46
- async prompt(questions, initialAnswers) {
47
- const answers = await this.prompter.prompt(questions, initialAnswers);
48
- return answers;
49
- }
50
- /**
51
- * Overwrite the deployables property on the class.
52
- */
53
- selectDeployables(deployables) {
54
- this.deployables = Object.assign([], deployables);
55
- }
56
- }
57
- exports.Deployer = Deployer;
58
- //# sourceMappingURL=deployer.js.map
package/lib/hooks.d.ts DELETED
@@ -1,34 +0,0 @@
1
- import { Config } from '@oclif/core/lib/interfaces/config';
2
- import { Hook, Hooks } from '@oclif/core/lib/interfaces/hooks';
3
- import { Deployer } from './deployer';
4
- import { EnvList, EnvDisplay, JsonObject, Deploy, Login, Logout } from './types';
5
- import { Deauthorizer } from './deauthorizer';
6
- /**
7
- * Interface that defines the well known Unified CLI command hooks.
8
- */
9
- interface SfHooks<T = unknown> extends Hooks {
10
- 'sf:env:list': EnvList.HookMeta<T & JsonObject>;
11
- 'sf:env:display': EnvDisplay.HookMeta<T & JsonObject>;
12
- 'sf:deploy': Deploy.HookMeta<T & Deployer>;
13
- 'sf:login': Login.HookMeta;
14
- 'sf:logout': Logout.HookMeta<T & Deauthorizer>;
15
- }
16
- type GenericHook<T extends keyof SfHooks, P> = Hook<T, SfHooks<P>>;
17
- /**
18
- * Class that provides a static method to run a pre-defined sf hook. See {@link SfHooks}.
19
- */
20
- export declare class SfHook {
21
- /**
22
- * Executes a well known Unified CLI hook. See {@link SfHooks}.
23
- */
24
- static run<T extends keyof SfHooks>(config: Config, hookName: T, options?: SfHooks[T]['options']): Promise<Hook.Result<SfHooks[T]['return']>>;
25
- }
26
- export declare namespace SfHook {
27
- type EnvList<T> = GenericHook<'sf:env:list', T>;
28
- type EnvDisplay<T> = GenericHook<'sf:env:display', T>;
29
- type Deploy<T> = GenericHook<'sf:deploy', T>;
30
- type Login = Hook<'sf:login', SfHooks>;
31
- type Logout = Hook<'sf:logout', SfHooks>;
32
- }
33
- export {};
34
- //# sourceMappingURL=hooks.d.ts.map
package/lib/hooks.js DELETED
@@ -1,30 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2022, salesforce.com, inc.
4
- * All rights reserved.
5
- * Licensed under the BSD 3-Clause license.
6
- * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.SfHook = void 0;
10
- const kit_1 = require("@salesforce/kit");
11
- const core_1 = require("@oclif/core");
12
- /**
13
- * Class that provides a static method to run a pre-defined sf hook. See {@link SfHooks}.
14
- */
15
- class SfHook {
16
- /**
17
- * Executes a well known Unified CLI hook. See {@link SfHooks}.
18
- */
19
- static async run(config, hookName, options = {}) {
20
- const timeout = kit_1.Duration.milliseconds(kit_1.env.getNumber('SF_HOOK_TIMEOUT_MS') ?? 5000);
21
- const results = await config.runHook(hookName, options, timeout.milliseconds, true);
22
- results.failures.forEach((failure) => {
23
- core_1.ux.debug(`Failed to run ${hookName} hook for ${failure.plugin.name}`);
24
- core_1.ux.debug(failure.error.toString());
25
- });
26
- return results;
27
- }
28
- }
29
- exports.SfHook = SfHook;
30
- //# sourceMappingURL=hooks.js.map
@@ -1,128 +0,0 @@
1
- import { Deauthorizer } from '../deauthorizer';
2
- import { Deployer } from '../deployer';
3
- export type JsonObject = {
4
- [key: string]: string | string[] | number | number[] | boolean | boolean[] | null | undefined;
5
- };
6
- /**
7
- * By default `sf env display` will display every key/value returned by the hook.
8
- * It will also Title Case every key for readability. To overwrite this behavior,
9
- * you can specify how a key should be displayed to the user.
10
- *
11
- * @example
12
- *
13
- * ```
14
- * { data: { theURL: 'https://example.com' } }
15
- * // Renders as:
16
- * Key Value
17
- * ------- -------------------
18
- * The URL https://example.com
19
- * ```
20
- *
21
- * @example
22
- *
23
- * ```
24
- * {
25
- * data: { theURL: 'https://example.com' }
26
- * keys: { theURL: 'Url' },
27
- * }
28
- * // Renders as:
29
- * Key Value
30
- * --- -------------------
31
- * Url https://example.com
32
- *```
33
- * If no environment matches the provided targetEnv, then return null in the data field.
34
- *
35
- * @example
36
- * ```
37
- * { data: null }
38
- * ```
39
- */
40
- export declare namespace EnvDisplay {
41
- type Keys<T> = Record<keyof T, string>;
42
- export type HookMeta<T extends JsonObject> = {
43
- options: {
44
- targetEnv: string;
45
- };
46
- return: {
47
- data: T | null;
48
- keys?: Keys<T>;
49
- };
50
- };
51
- export {};
52
- }
53
- /**
54
- * By default `sf env list` will render a table with all the data provided by the hook.
55
- * The columns of the table are derived from the keys of the provided data. These column
56
- * headers are Title Cased for readability. To overwrite a column name specify it with
57
- * the `keys` property.
58
- *
59
- * @example
60
- *
61
- * ```
62
- * {
63
- * title: 'My Envs',
64
- * data: [{ username: 'foo', theURL: 'https://example.com' }]
65
- * }
66
- * // Renders as:
67
- * My Envs
68
- * ================================
69
- * | Username | The URL
70
- * | foo | https://example.com
71
- *```
72
- *
73
- * @example
74
- *
75
- * ```
76
- * {
77
- * data: [{ username: 'foo', theURL: 'https://example.com' }]
78
- * keys: { theURL: 'Url', username: 'Name' },
79
- * }
80
- *
81
- * // Renders as:
82
- * My Envs
83
- * ============================
84
- * | Name | Url
85
- * | foo | https://example.com
86
- *
87
- *```
88
- */
89
- export declare namespace EnvList {
90
- export enum EnvType {
91
- 'salesforceOrgs' = "salesforceOrgs",
92
- 'scratchOrgs' = "scratchOrgs",
93
- 'computeEnvs' = "computeEnvs"
94
- }
95
- export type Table<T extends JsonObject> = {
96
- type: EnvType | string;
97
- data: T[];
98
- keys?: Record<keyof T, string>;
99
- title: string;
100
- };
101
- type Options = {
102
- all: boolean;
103
- };
104
- export type HookMeta<T extends JsonObject> = {
105
- options: Options;
106
- return: Array<Table<T>>;
107
- };
108
- export {};
109
- }
110
- export declare namespace Deploy {
111
- type HookMeta<T extends Deployer> = {
112
- options: Record<string, unknown>;
113
- return: T[];
114
- };
115
- }
116
- export declare namespace Login {
117
- type HookMeta = {
118
- options: Record<string, unknown>;
119
- return: void;
120
- };
121
- }
122
- export declare namespace Logout {
123
- type HookMeta<T extends Deauthorizer> = {
124
- options: Record<string, unknown>;
125
- return: T;
126
- };
127
- }
128
- //# sourceMappingURL=index.d.ts.map
@@ -1,55 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2022, salesforce.com, inc.
4
- * All rights reserved.
5
- * Licensed under the BSD 3-Clause license.
6
- * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.EnvList = void 0;
10
- /**
11
- * By default `sf env list` will render a table with all the data provided by the hook.
12
- * The columns of the table are derived from the keys of the provided data. These column
13
- * headers are Title Cased for readability. To overwrite a column name specify it with
14
- * the `keys` property.
15
- *
16
- * @example
17
- *
18
- * ```
19
- * {
20
- * title: 'My Envs',
21
- * data: [{ username: 'foo', theURL: 'https://example.com' }]
22
- * }
23
- * // Renders as:
24
- * My Envs
25
- * ================================
26
- * | Username | The URL
27
- * | foo | https://example.com
28
- *```
29
- *
30
- * @example
31
- *
32
- * ```
33
- * {
34
- * data: [{ username: 'foo', theURL: 'https://example.com' }]
35
- * keys: { theURL: 'Url', username: 'Name' },
36
- * }
37
- *
38
- * // Renders as:
39
- * My Envs
40
- * ============================
41
- * | Name | Url
42
- * | foo | https://example.com
43
- *
44
- *```
45
- */
46
- var EnvList;
47
- (function (EnvList) {
48
- let EnvType;
49
- (function (EnvType) {
50
- EnvType["salesforceOrgs"] = "salesforceOrgs";
51
- EnvType["scratchOrgs"] = "scratchOrgs";
52
- EnvType["computeEnvs"] = "computeEnvs";
53
- })(EnvType = EnvList.EnvType || (EnvList.EnvType = {}));
54
- })(EnvList = exports.EnvList || (exports.EnvList = {}));
55
- //# sourceMappingURL=index.js.map
package/lib/ux/index.d.ts DELETED
@@ -1,6 +0,0 @@
1
- export { UxBase } from './base';
2
- export { Ux } from './ux';
3
- export { Progress } from './progress';
4
- export { Prompter, generateTableChoices, Separator } from './prompter';
5
- export { Spinner } from './spinner';
6
- //# sourceMappingURL=index.d.ts.map
package/lib/ux/index.js DELETED
@@ -1,22 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2022, salesforce.com, inc.
4
- * All rights reserved.
5
- * Licensed under the BSD 3-Clause license.
6
- * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.Spinner = exports.Separator = exports.generateTableChoices = exports.Prompter = exports.Progress = exports.Ux = exports.UxBase = void 0;
10
- var base_1 = require("./base");
11
- Object.defineProperty(exports, "UxBase", { enumerable: true, get: function () { return base_1.UxBase; } });
12
- var ux_1 = require("./ux");
13
- Object.defineProperty(exports, "Ux", { enumerable: true, get: function () { return ux_1.Ux; } });
14
- var progress_1 = require("./progress");
15
- Object.defineProperty(exports, "Progress", { enumerable: true, get: function () { return progress_1.Progress; } });
16
- var prompter_1 = require("./prompter");
17
- Object.defineProperty(exports, "Prompter", { enumerable: true, get: function () { return prompter_1.Prompter; } });
18
- Object.defineProperty(exports, "generateTableChoices", { enumerable: true, get: function () { return prompter_1.generateTableChoices; } });
19
- Object.defineProperty(exports, "Separator", { enumerable: true, get: function () { return prompter_1.Separator; } });
20
- var spinner_1 = require("./spinner");
21
- Object.defineProperty(exports, "Spinner", { enumerable: true, get: function () { return spinner_1.Spinner; } });
22
- //# sourceMappingURL=index.js.map
@@ -1,40 +0,0 @@
1
- import { QuestionCollection, Separator, ChoiceBase } from 'inquirer';
2
- import { Dictionary, Nullable } from '@salesforce/ts-types';
3
- export declare class Prompter {
4
- /**
5
- * Prompt user for information. See https://www.npmjs.com/package/inquirer for more.
6
- */
7
- prompt<T extends Prompter.Answers>(questions: Prompter.Questions<T>, initialAnswers?: Partial<T>): Promise<T>;
8
- /**
9
- * Prompt user for information with a timeout (in milliseconds). See https://www.npmjs.com/package/inquirer for more.
10
- */
11
- timedPrompt<T extends Prompter.Answers>(questions: Prompter.Questions<T>, ms?: number, initialAnswers?: Partial<T>): Promise<T>;
12
- /**
13
- * Simplified prompt for single-question confirmation. Times out and throws after 10s
14
- *
15
- * @param message text to display. Do not include a question mark.
16
- * @param ms milliseconds to wait for user input. Defaults to 10s.
17
- * @param defaultAnswer default answer for the prompt. Defaults to true. Pass in `false` to require a positive response.
18
- * @return true if the user confirms, false if they do not.
19
- */
20
- confirm(message: string, ms?: number, defaultAnswer?: boolean): Promise<boolean>;
21
- }
22
- export declare namespace Prompter {
23
- type Answers<T = Record<string, unknown>> = T & Record<string, unknown>;
24
- type Questions<T extends Answers> = QuestionCollection<T>;
25
- }
26
- /**
27
- * Generate a formatted table for list and checkbox prompts
28
- *
29
- * Each option should contain the same keys as specified in columns.
30
- *
31
- * @example
32
- * ```
33
- * const columns = { name: 'Name', type: 'Type', path: 'Path' };
34
- * const options = [{ name: 'foo', type: 'org', path: '/path/to/foo/' }];
35
- * generateTableChoices(columns, options);
36
- * ```
37
- */
38
- export declare function generateTableChoices<T>(columns: Dictionary<string>, choices: Array<Dictionary<Nullable<string> | T>>, padForCheckbox?: boolean): ChoiceBase[];
39
- export { Separator };
40
- //# sourceMappingURL=prompter.d.ts.map
@@ -1,99 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2022, salesforce.com, inc.
4
- * All rights reserved.
5
- * Licensed under the BSD 3-Clause license.
6
- * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.Separator = exports.generateTableChoices = exports.Prompter = void 0;
10
- const inquirer_1 = require("inquirer");
11
- Object.defineProperty(exports, "Separator", { enumerable: true, get: function () { return inquirer_1.Separator; } });
12
- const ts_types_1 = require("@salesforce/ts-types");
13
- const core_1 = require("@oclif/core");
14
- class Prompter {
15
- /**
16
- * Prompt user for information. See https://www.npmjs.com/package/inquirer for more.
17
- */
18
- // eslint-disable-next-line class-methods-use-this
19
- async prompt(questions, initialAnswers) {
20
- const answers = await (0, inquirer_1.prompt)(questions, initialAnswers);
21
- return answers;
22
- }
23
- /**
24
- * Prompt user for information with a timeout (in milliseconds). See https://www.npmjs.com/package/inquirer for more.
25
- */
26
- // eslint-disable-next-line class-methods-use-this
27
- async timedPrompt(questions, ms = 10000, initialAnswers) {
28
- let id;
29
- const thePrompt = (0, inquirer_1.prompt)(questions, initialAnswers);
30
- const timeout = new Promise((_, reject) => {
31
- id = setTimeout(() => {
32
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
33
- // @ts-expect-error
34
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call
35
- thePrompt.ui['activePrompt'].done();
36
- core_1.ux.log();
37
- reject(new Error(`Timed out after ${ms} ms.`));
38
- }, ms).unref();
39
- });
40
- return Promise.race([timeout, thePrompt]).then((result) => {
41
- clearTimeout(id);
42
- return result;
43
- });
44
- }
45
- /**
46
- * Simplified prompt for single-question confirmation. Times out and throws after 10s
47
- *
48
- * @param message text to display. Do not include a question mark.
49
- * @param ms milliseconds to wait for user input. Defaults to 10s.
50
- * @param defaultAnswer default answer for the prompt. Defaults to true. Pass in `false` to require a positive response.
51
- * @return true if the user confirms, false if they do not.
52
- */
53
- async confirm(message, ms = 10000, defaultAnswer = true) {
54
- const { confirmed } = await this.timedPrompt([
55
- {
56
- name: 'confirmed',
57
- message,
58
- type: 'confirm',
59
- default: defaultAnswer,
60
- },
61
- ], ms);
62
- return confirmed;
63
- }
64
- }
65
- exports.Prompter = Prompter;
66
- /**
67
- * Generate a formatted table for list and checkbox prompts
68
- *
69
- * Each option should contain the same keys as specified in columns.
70
- *
71
- * @example
72
- * ```
73
- * const columns = { name: 'Name', type: 'Type', path: 'Path' };
74
- * const options = [{ name: 'foo', type: 'org', path: '/path/to/foo/' }];
75
- * generateTableChoices(columns, options);
76
- * ```
77
- */
78
- function generateTableChoices(columns, choices,
79
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
80
- padForCheckbox = true) {
81
- const columnEntries = Object.entries(columns);
82
- const columnLengths = columnEntries.map(([key, value]) => Math.max((0, ts_types_1.ensureString)(value).length, ...choices.map((option) => (0, ts_types_1.ensureString)(option[key], `Type ${typeof option[key]} for ${key} in ${Object.keys(option).join(', ')}`)
83
- .length)) + 1);
84
- const choicesOptions = [
85
- new inquirer_1.Separator(`${padForCheckbox ? ' '.repeat(2) : ''}${columnEntries
86
- .map(([, value], index) => value?.padEnd(columnLengths[index], ' '))
87
- .join('')}`),
88
- ];
89
- for (const meta of choices) {
90
- const name = columnEntries
91
- .map(([key], index) => (0, ts_types_1.ensureString)(meta[key]).padEnd(columnLengths[index], ' '))
92
- .join('');
93
- const choice = { name, value: meta.value, short: (0, ts_types_1.ensureString)(meta.name) };
94
- choicesOptions.push(choice);
95
- }
96
- return choicesOptions;
97
- }
98
- exports.generateTableChoices = generateTableChoices;
99
- //# sourceMappingURL=prompter.js.map