@salesforce/sf-plugins-core 1.0.5 → 1.1.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/CHANGELOG.md +11 -0
- package/LICENSE.txt +1 -1
- package/lib/sfCommand.d.ts +4 -1
- package/lib/sfCommand.js +5 -3
- package/lib/ux.d.ts +30 -0
- package/lib/ux.js +55 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
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.1.0](https://github.com/salesforcecli/sf-plugins-core/compare/v1.0.5...v1.1.0) (2022-01-03)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
- add spinner methods ([f209f8f](https://github.com/salesforcecli/sf-plugins-core/commit/f209f8f4e6736b9de91e37f865d66b5356e5abec))
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
- add status method ([9cf2069](https://github.com/salesforcecli/sf-plugins-core/commit/9cf20694d76e2509785b7c8faa4bd63ab190707e))
|
|
14
|
+
- make status a getter/setter ([441c55a](https://github.com/salesforcecli/sf-plugins-core/commit/441c55acd3d811664213e9801a8bcc270e3aca7b))
|
|
15
|
+
|
|
5
16
|
### [1.0.5](https://github.com/salesforcecli/sf-plugins-core/compare/v1.0.4...v1.0.5) (2021-12-16)
|
|
6
17
|
|
|
7
18
|
### Bug Fixes
|
package/LICENSE.txt
CHANGED
package/lib/sfCommand.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Command, HelpSection, Interfaces } from '@oclif/core';
|
|
1
|
+
import { Command, Config, HelpSection, Interfaces } from '@oclif/core';
|
|
2
|
+
import { Spinner } from './ux';
|
|
2
3
|
export interface SfCommandInterface extends Interfaces.Command {
|
|
3
4
|
configurationVariablesSection?: HelpSection;
|
|
4
5
|
envVariablesSection?: HelpSection;
|
|
@@ -17,7 +18,9 @@ export declare abstract class SfCommand<T> extends Command {
|
|
|
17
18
|
static configurationVariablesSection?: HelpSection;
|
|
18
19
|
static envVariablesSection?: HelpSection;
|
|
19
20
|
static errorCodes?: HelpSection;
|
|
21
|
+
spinner: Spinner;
|
|
20
22
|
private warnings;
|
|
23
|
+
constructor(argv: string[], config: Config);
|
|
21
24
|
/**
|
|
22
25
|
* Log warning to users. If --json is enabled, then the warning
|
|
23
26
|
* will be added to the json output under the warnings property.
|
package/lib/sfCommand.js
CHANGED
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SfCommand = void 0;
|
|
4
4
|
/*
|
|
5
|
-
* Copyright (c)
|
|
5
|
+
* Copyright (c) 2021, salesforce.com, inc.
|
|
6
6
|
* All rights reserved.
|
|
7
7
|
* Licensed under the BSD 3-Clause license.
|
|
8
8
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
9
9
|
*/
|
|
10
10
|
const core_1 = require("@oclif/core");
|
|
11
11
|
const core_2 = require("@salesforce/core");
|
|
12
|
+
const ux_1 = require("./ux");
|
|
12
13
|
core_2.Messages.importMessagesDirectory(__dirname);
|
|
13
14
|
const messages = core_2.Messages.loadMessages('@salesforce/sf-plugins-core', 'messages');
|
|
14
15
|
/**
|
|
@@ -20,9 +21,10 @@ const messages = core_2.Messages.loadMessages('@salesforce/sf-plugins-core', 'me
|
|
|
20
21
|
* @see https://github.com/oclif/core/blob/main/src/command.ts
|
|
21
22
|
*/
|
|
22
23
|
class SfCommand extends core_1.Command {
|
|
23
|
-
constructor() {
|
|
24
|
-
super(
|
|
24
|
+
constructor(argv, config) {
|
|
25
|
+
super(argv, config);
|
|
25
26
|
this.warnings = [];
|
|
27
|
+
this.spinner = new ux_1.Spinner(this.jsonEnabled());
|
|
26
28
|
}
|
|
27
29
|
/**
|
|
28
30
|
* Log warning to users. If --json is enabled, then the warning
|
package/lib/ux.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This class is a light wrapper around cli.action that allows us to
|
|
3
|
+
* automatically suppress any actions if `--json` flag is present.
|
|
4
|
+
*/
|
|
5
|
+
export declare class Spinner {
|
|
6
|
+
private jsonEnabled;
|
|
7
|
+
constructor(jsonEnabled: boolean);
|
|
8
|
+
/**
|
|
9
|
+
* Start a spinner on the console.
|
|
10
|
+
*/
|
|
11
|
+
start(action: string, status?: string, opts?: {
|
|
12
|
+
stdout?: boolean;
|
|
13
|
+
}): void;
|
|
14
|
+
/**
|
|
15
|
+
* Stop the spinner on the console.
|
|
16
|
+
*/
|
|
17
|
+
stop(msg?: string): void;
|
|
18
|
+
/**
|
|
19
|
+
* Set the status of the current spinner.
|
|
20
|
+
*/
|
|
21
|
+
set status(status: string | undefined);
|
|
22
|
+
/**
|
|
23
|
+
* Get the status of the current spinner.
|
|
24
|
+
*/
|
|
25
|
+
get status(): string | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Pause the spinner on the console.
|
|
28
|
+
*/
|
|
29
|
+
pause(fn: () => unknown, icon?: string): void;
|
|
30
|
+
}
|
package/lib/ux.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2021, 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 = void 0;
|
|
10
|
+
const cli_ux_1 = require("cli-ux");
|
|
11
|
+
/**
|
|
12
|
+
* This class is a light wrapper around cli.action that allows us to
|
|
13
|
+
* automatically suppress any actions if `--json` flag is present.
|
|
14
|
+
*/
|
|
15
|
+
class Spinner {
|
|
16
|
+
constructor(jsonEnabled) {
|
|
17
|
+
this.jsonEnabled = jsonEnabled;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Start a spinner on the console.
|
|
21
|
+
*/
|
|
22
|
+
start(action, status, opts) {
|
|
23
|
+
if (!this.jsonEnabled)
|
|
24
|
+
cli_ux_1.cli.action.start(action, status, opts);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Stop the spinner on the console.
|
|
28
|
+
*/
|
|
29
|
+
stop(msg) {
|
|
30
|
+
if (!this.jsonEnabled)
|
|
31
|
+
cli_ux_1.cli.action.stop(msg);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Set the status of the current spinner.
|
|
35
|
+
*/
|
|
36
|
+
set status(status) {
|
|
37
|
+
if (!this.jsonEnabled)
|
|
38
|
+
cli_ux_1.cli.action.status = status;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Get the status of the current spinner.
|
|
42
|
+
*/
|
|
43
|
+
get status() {
|
|
44
|
+
return cli_ux_1.cli.action.status;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Pause the spinner on the console.
|
|
48
|
+
*/
|
|
49
|
+
pause(fn, icon) {
|
|
50
|
+
if (!this.jsonEnabled)
|
|
51
|
+
cli_ux_1.cli.action.pause(fn, icon);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.Spinner = Spinner;
|
|
55
|
+
//# sourceMappingURL=ux.js.map
|