@salesforce/sf-plugins-core 1.2.1 → 1.3.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 +6 -0
- package/lib/sfCommand.d.ts +6 -0
- package/lib/sfCommand.js +20 -0
- package/messages/messages.md +4 -0
- package/package.json +1 -1
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.3.0](https://github.com/salesforcecli/sf-plugins-core/compare/v1.2.1...v1.3.0) (2022-02-23)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
- add requiresProject property ([5ff0cf3](https://github.com/salesforcecli/sf-plugins-core/commit/5ff0cf34fffe896e1ed312585705ff13436e58cf))
|
|
10
|
+
|
|
5
11
|
### [1.2.1](https://github.com/salesforcecli/sf-plugins-core/compare/v1.2.0...v1.2.1) (2022-01-27)
|
|
6
12
|
|
|
7
13
|
### Bug Fixes
|
package/lib/sfCommand.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CliUx, Command, Config, HelpSection, Interfaces } from '@oclif/core';
|
|
2
|
+
import { SfdxProject } from '@salesforce/core';
|
|
2
3
|
import { AnyJson } from '@salesforce/ts-types';
|
|
3
4
|
import { Progress, Prompter, Spinner, Ux } from './ux';
|
|
4
5
|
export interface SfCommandInterface extends Interfaces.Command {
|
|
@@ -20,11 +21,14 @@ export declare abstract class SfCommand<T> extends Command {
|
|
|
20
21
|
static envVariablesSection?: HelpSection;
|
|
21
22
|
static errorCodes?: HelpSection;
|
|
22
23
|
static tableFlags: typeof CliUx.Table.table.flags;
|
|
24
|
+
static requiresProject: boolean;
|
|
23
25
|
spinner: Spinner;
|
|
24
26
|
progress: Progress;
|
|
27
|
+
project: SfdxProject;
|
|
25
28
|
private warnings;
|
|
26
29
|
private ux;
|
|
27
30
|
private prompter;
|
|
31
|
+
protected get statics(): typeof SfCommand;
|
|
28
32
|
constructor(argv: string[], config: Config);
|
|
29
33
|
/**
|
|
30
34
|
* Log warning to users. If --json is enabled, then the warning
|
|
@@ -66,6 +70,7 @@ export declare abstract class SfCommand<T> extends Command {
|
|
|
66
70
|
* }
|
|
67
71
|
*/
|
|
68
72
|
prompt<R = Prompter.Answers>(questions: Prompter.Questions<R>, initialAnswers?: Partial<R>): Promise<R>;
|
|
73
|
+
_run<R>(): Promise<R | undefined>;
|
|
69
74
|
/**
|
|
70
75
|
* Wrap the command result into the standardized JSON structure.
|
|
71
76
|
*/
|
|
@@ -74,6 +79,7 @@ export declare abstract class SfCommand<T> extends Command {
|
|
|
74
79
|
* Wrap the command error into the standardized JSON structure.
|
|
75
80
|
*/
|
|
76
81
|
protected toErrorJson(error: Error): SfCommand.Error;
|
|
82
|
+
protected assignProject(): Promise<SfdxProject>;
|
|
77
83
|
abstract run(): Promise<T>;
|
|
78
84
|
}
|
|
79
85
|
export declare namespace SfCommand {
|
package/lib/sfCommand.js
CHANGED
|
@@ -30,6 +30,9 @@ class SfCommand extends core_1.Command {
|
|
|
30
30
|
this.ux = new ux_1.Ux(outputEnabled);
|
|
31
31
|
this.prompter = new ux_1.Prompter();
|
|
32
32
|
}
|
|
33
|
+
get statics() {
|
|
34
|
+
return this.constructor;
|
|
35
|
+
}
|
|
33
36
|
/**
|
|
34
37
|
* Log warning to users. If --json is enabled, then the warning
|
|
35
38
|
* will be added to the json output under the warnings property.
|
|
@@ -87,6 +90,12 @@ class SfCommand extends core_1.Command {
|
|
|
87
90
|
async prompt(questions, initialAnswers) {
|
|
88
91
|
return this.prompter.prompt(questions, initialAnswers);
|
|
89
92
|
}
|
|
93
|
+
async _run() {
|
|
94
|
+
if (this.statics.requiresProject) {
|
|
95
|
+
this.project = await this.assignProject();
|
|
96
|
+
}
|
|
97
|
+
return super._run();
|
|
98
|
+
}
|
|
90
99
|
/**
|
|
91
100
|
* Wrap the command result into the standardized JSON structure.
|
|
92
101
|
*/
|
|
@@ -111,6 +120,17 @@ class SfCommand extends core_1.Command {
|
|
|
111
120
|
warnings: this.warnings,
|
|
112
121
|
};
|
|
113
122
|
}
|
|
123
|
+
async assignProject() {
|
|
124
|
+
try {
|
|
125
|
+
return await core_2.SfdxProject.resolve();
|
|
126
|
+
}
|
|
127
|
+
catch (err) {
|
|
128
|
+
if (err instanceof Error && err.name === 'InvalidProjectWorkspaceError') {
|
|
129
|
+
throw messages.createError('errors.RequiresProject');
|
|
130
|
+
}
|
|
131
|
+
throw err;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
114
134
|
}
|
|
115
135
|
exports.SfCommand = SfCommand;
|
|
116
136
|
SfCommand.enableJsonFlag = true;
|
package/messages/messages.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
# warning.security
|
|
2
2
|
|
|
3
3
|
This command will expose sensitive information that allows for subsequent activity using your current authenticated session. Sharing this information is equivalent to logging someone in under the current credential, resulting in unintended access and escalation of privilege. For additional information, please review the authorization section of the https://developer.salesforce.com/docs/atlas.en-us.234.0.sfdx_dev.meta/sfdx_dev/sfdx_dev_auth_web_flow.htm
|
|
4
|
+
|
|
5
|
+
# errors.RequiresProject
|
|
6
|
+
|
|
7
|
+
This command is required to run from within a Salesforce project directory.
|