Skip to content
This repository was archived by the owner on Nov 5, 2023. It is now read-only.

Commit 1bc740b

Browse files
committed
add execution time in response
1 parent 07bfc8a commit 1bc740b

File tree

10 files changed

+434
-362
lines changed

10 files changed

+434
-362
lines changed

oclif.manifest.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"version":"0.3.1","commands":{"deploy:apex":{"id":"deploy:apex","description":"Deploy apex class using tooling api","usage":"<%= command.id %> -p <string> [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]","pluginName":"mo-dx-plugin","pluginType":"core","aliases":[],"examples":["$ sfdx deploy:apex -p filepath"],"flags":{"json":{"name":"json","type":"boolean","description":"format output as json","allowNo":false},"loglevel":{"name":"loglevel","type":"option","description":"logging level for this command invocation","required":false,"helpValue":"(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)","options":["trace","debug","info","warn","error","fatal","TRACE","DEBUG","INFO","WARN","ERROR","FATAL"],"default":"warn"},"targetusername":{"name":"targetusername","type":"option","char":"u","description":"username or alias for the target org; overrides default target org"},"apiversion":{"name":"apiversion","type":"option","description":"override the api version used for api requests made by this command"},"filepath":{"name":"filepath","type":"option","char":"p","description":"file path","required":true}},"args":[]},"deploy:aura":{"id":"deploy:aura","description":"Deploy aura bundles using tooling api","usage":"<%= command.id %> -p <string> [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]","pluginName":"mo-dx-plugin","pluginType":"core","aliases":[],"examples":["$ sfdx deploy:aura -p filepath"],"flags":{"json":{"name":"json","type":"boolean","description":"format output as json","allowNo":false},"loglevel":{"name":"loglevel","type":"option","description":"logging level for this command invocation","required":false,"helpValue":"(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)","options":["trace","debug","info","warn","error","fatal","TRACE","DEBUG","INFO","WARN","ERROR","FATAL"],"default":"warn"},"targetusername":{"name":"targetusername","type":"option","char":"u","description":"username or alias for the target org; overrides default target org"},"apiversion":{"name":"apiversion","type":"option","description":"override the api version used for api requests made by this command"},"filepath":{"name":"filepath","type":"option","char":"p","description":"file path","required":true}},"args":[]},"deploy:lwc":{"id":"deploy:lwc","description":"Deploy lwc wusing tooling api","usage":"<%= command.id %> [-p <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]","pluginName":"mo-dx-plugin","pluginType":"core","aliases":[],"examples":["$ sfdx deploy:lwc -p filepath"],"flags":{"json":{"name":"json","type":"boolean","description":"format output as json","allowNo":false},"loglevel":{"name":"loglevel","type":"option","description":"logging level for this command invocation","required":false,"helpValue":"(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)","options":["trace","debug","info","warn","error","fatal","TRACE","DEBUG","INFO","WARN","ERROR","FATAL"],"default":"warn"},"targetusername":{"name":"targetusername","type":"option","char":"u","description":"username or alias for the target org; overrides default target org"},"apiversion":{"name":"apiversion","type":"option","description":"override the api version used for api requests made by this command"},"filepath":{"name":"filepath","type":"option","char":"p","description":"file path"}},"args":[]},"deploy:staticresource":{"id":"deploy:staticresource","description":"Deploy static resource using tooling api","usage":"<%= command.id %> [-p <string>] [-r <string>] [-c <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]","pluginName":"mo-dx-plugin","pluginType":"core","aliases":[],"examples":["$ sfdx deploy:staticresource -p <filepath>","$ sfdx deploy:staticresource -p <filepath> --cachecontrol public","$ sfdx deploy:staticresource -p <filepath> --cachecontrol public --resourcefolder <name of the folder where you have single page app>"],"flags":{"json":{"name":"json","type":"boolean","description":"format output as json","allowNo":false},"loglevel":{"name":"loglevel","type":"option","description":"logging level for this command invocation","required":false,"helpValue":"(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)","options":["trace","debug","info","warn","error","fatal","TRACE","DEBUG","INFO","WARN","ERROR","FATAL"],"default":"warn"},"targetusername":{"name":"targetusername","type":"option","char":"u","description":"username or alias for the target org; overrides default target org"},"apiversion":{"name":"apiversion","type":"option","description":"override the api version used for api requests made by this command"},"filepath":{"name":"filepath","type":"option","char":"p","description":"file path of the resource bundle"},"resourcefolder":{"name":"resourcefolder","type":"option","char":"r","description":"name of the folder where you have single page app, This defaults to staticresources","default":"staticresources"},"cachecontrol":{"name":"cachecontrol","type":"option","char":"c","description":"cache control, defaults to public","default":"private"}},"args":[]},"deploy:trigger":{"id":"deploy:trigger","description":"Deploy apex triggers using tooling api","usage":"<%= command.id %> -p <string> [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]","pluginName":"mo-dx-plugin","pluginType":"core","aliases":[],"examples":["$ sfdx deploy:trigger -p filepath"],"flags":{"json":{"name":"json","type":"boolean","description":"format output as json","allowNo":false},"loglevel":{"name":"loglevel","type":"option","description":"logging level for this command invocation","required":false,"helpValue":"(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)","options":["trace","debug","info","warn","error","fatal","TRACE","DEBUG","INFO","WARN","ERROR","FATAL"],"default":"warn"},"targetusername":{"name":"targetusername","type":"option","char":"u","description":"username or alias for the target org; overrides default target org"},"apiversion":{"name":"apiversion","type":"option","description":"override the api version used for api requests made by this command"},"filepath":{"name":"filepath","type":"option","char":"p","description":"file path","required":true}},"args":[]},"deploy:vf":{"id":"deploy:vf","description":"Deploy visualforce page using tooling api","usage":"<%= command.id %> -p <string> [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]","pluginName":"mo-dx-plugin","pluginType":"core","aliases":[],"examples":["$ sfdx deploy:vf -p filepath"],"flags":{"json":{"name":"json","type":"boolean","description":"format output as json","allowNo":false},"loglevel":{"name":"loglevel","type":"option","description":"logging level for this command invocation","required":false,"helpValue":"(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)","options":["trace","debug","info","warn","error","fatal","TRACE","DEBUG","INFO","WARN","ERROR","FATAL"],"default":"warn"},"targetusername":{"name":"targetusername","type":"option","char":"u","description":"username or alias for the target org; overrides default target org"},"apiversion":{"name":"apiversion","type":"option","description":"override the api version used for api requests made by this command"},"filepath":{"name":"filepath","type":"option","char":"p","description":"file path","required":true}},"args":[]},"deploy:vfcomponent":{"id":"deploy:vfcomponent","description":"Deploy visualforce components using tooling api","usage":"<%= command.id %> -p <string> [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]","pluginName":"mo-dx-plugin","pluginType":"core","aliases":[],"examples":["$ sfdx deploy:vfcomponent -p filepath"],"flags":{"json":{"name":"json","type":"boolean","description":"format output as json","allowNo":false},"loglevel":{"name":"loglevel","type":"option","description":"logging level for this command invocation","required":false,"helpValue":"(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)","options":["trace","debug","info","warn","error","fatal","TRACE","DEBUG","INFO","WARN","ERROR","FATAL"],"default":"warn"},"targetusername":{"name":"targetusername","type":"option","char":"u","description":"username or alias for the target org; overrides default target org"},"apiversion":{"name":"apiversion","type":"option","description":"override the api version used for api requests made by this command"},"filepath":{"name":"filepath","type":"option","char":"p","description":"file path","required":true}},"args":[]},"metadata:rename":{"id":"metadata:rename","description":"Rename metadata using metadata api","usage":"<%= command.id %> -t <string> -n <string> -o <string> [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]","pluginName":"mo-dx-plugin","pluginType":"core","aliases":[],"examples":["$ sfdx metadata:rename -t <metadatatype> -n <newname> -o <oldname>","$ sfdx metadata:rename -t CustomObject -n MyCustomObject1New__c -o MyCustomObject1__c"],"flags":{"json":{"name":"json","type":"boolean","description":"format output as json","allowNo":false},"loglevel":{"name":"loglevel","type":"option","description":"logging level for this command invocation","required":false,"helpValue":"(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)","options":["trace","debug","info","warn","error","fatal","TRACE","DEBUG","INFO","WARN","ERROR","FATAL"],"default":"warn"},"targetusername":{"name":"targetusername","type":"option","char":"u","description":"username or alias for the target org; overrides default target org"},"apiversion":{"name":"apiversion","type":"option","description":"override the api version used for api requests made by this command"},"metadatatype":{"name":"metadatatype","type":"option","char":"t","description":"type of the metadata. Examples are CustomObject, Profile","required":true},"newfullname":{"name":"newfullname","type":"option","char":"n","description":"new name of the metadata element","required":true},"oldfullname":{"name":"oldfullname","type":"option","char":"o","description":"old name of the metadata element","required":true}},"args":[]},"retrieve:dxsource":{"id":"retrieve:dxsource","description":"Retrieves Source is DX format from Unmanaged/Managed package","usage":"<%= command.id %> -n <string> [-p <string>] [-m <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]","pluginName":"mo-dx-plugin","pluginType":"core","aliases":[],"examples":["$ sfdx retrieve:dxsource -n <package/changeset>","$ sfdx retrieve:dxsource -n <package/changeset> -m \"true\"","$ sfdx retrieve:dxsource -n <package/changeset> -p <[pathName]>","$ sfdx retrieve:dxsource -u myOrg@example.com -n <package/changeset> -p <[pathName]>"],"flags":{"json":{"name":"json","type":"boolean","description":"format output as json","allowNo":false},"loglevel":{"name":"loglevel","type":"option","description":"logging level for this command invocation","required":false,"helpValue":"(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)","options":["trace","debug","info","warn","error","fatal","TRACE","DEBUG","INFO","WARN","ERROR","FATAL"],"default":"warn"},"targetusername":{"name":"targetusername","type":"option","char":"u","description":"username or alias for the target org; overrides default target org"},"apiversion":{"name":"apiversion","type":"option","description":"override the api version used for api requests made by this command"},"packagename":{"name":"packagename","type":"option","char":"n","description":"the name of the package you want to retrieve","required":true},"pathname":{"name":"pathname","type":"option","char":"p","description":"where to convert the result to.defaults to force-app","default":"force-app"},"retainmetadata":{"name":"retainmetadata","type":"option","char":"m","description":"If set retain the metadata folder in mdapiout directory and do not clean"}},"args":[]},"retrieve:pkgsource":{"id":"retrieve:pkgsource","description":"Retrieves Source from Unmanaged/Managed package in Metadata API format","usage":"<%= command.id %> -n <string> [-r <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]","pluginName":"mo-dx-plugin","pluginType":"core","aliases":[],"examples":["$ sfdx retrieve:pkgsource -n <package/changeset>","$ sfdx retrieve:pkgsource -n <package/changeset> -r <relative path where source is retrieved and unzipped>","$ sfdx retrieve:pkgsource -n <package/changeset> -r /changesets/src"],"flags":{"json":{"name":"json","type":"boolean","description":"format output as json","allowNo":false},"loglevel":{"name":"loglevel","type":"option","description":"logging level for this command invocation","required":false,"helpValue":"(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)","options":["trace","debug","info","warn","error","fatal","TRACE","DEBUG","INFO","WARN","ERROR","FATAL"],"default":"warn"},"targetusername":{"name":"targetusername","type":"option","char":"u","description":"username or alias for the target org; overrides default target org"},"apiversion":{"name":"apiversion","type":"option","description":"override the api version used for api requests made by this command"},"packagename":{"name":"packagename","type":"option","char":"n","description":"the name of the package you want to retrieve","required":true},"retrievedir":{"name":"retrievedir","type":"option","char":"r","description":"directory path to retrieve","required":false}},"args":[]}}}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"@oclif/command": "^1.5.8",
88
"@oclif/config": "^1.12.6",
99
"@oclif/errors": "^1.2.2",
10-
"@salesforce/command": "^3.0.0",
10+
"@salesforce/command": "^3.0.3",
1111
"@salesforce/ts-types": "^1.0.1",
1212
"adm-zip": "^0.4.13",
1313
"chalk": "^3.0.0",
@@ -21,7 +21,7 @@
2121
"@oclif/dev-cli": "^1.21.0",
2222
"@oclif/plugin-help": "^2",
2323
"@oclif/test": "^1",
24-
"@salesforce/dev-config": "1.1.4",
24+
"@salesforce/dev-config": "2.0.0",
2525
"@types/adm-zip": "^0.4.31",
2626
"@types/chai": "^4",
2727
"@types/fs-extra": "^8.0.1",

src/commands/deploy/apex.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,14 @@ export default class ApexDeploy extends SfdxCommand {
3939
// Set this to true if your command requires a project workspace; 'requiresProject' is false by default
4040
protected static requiresProject = true;
4141

42+
private startTime: number ;
43+
44+
private endTime: number;
45+
4246
public async run(): Promise<AnyJson> {
4347

4448
this.ux.startSpinner(chalk.bold.yellowBright('Saving'));
49+
this.startTime = new Date().getTime();
4550

4651
const conn = this.org.getConnection();
4752

@@ -77,7 +82,9 @@ export default class ApexDeploy extends SfdxCommand {
7782
const deployAction = new Deploy('ApexContainer', 'ApexClassMember', className, classId, filebody, metadataXML, conn);
7883
const deployResult = await deployAction.deployMetadata() as DeployResult;
7984
if (deployResult.success) {
80-
this.ux.stopSpinner(chalk.bold.greenBright('Apex Class Successfully ' + mode + ' ✔'));
85+
this.endTime = new Date().getTime();
86+
const executionTime = (this.endTime - this.startTime) / 1000;
87+
this.ux.stopSpinner(chalk.bold.greenBright(`Apex Class Successfully ${mode} ✔.Command execution time: ${executionTime} seconds`));
8188
} else {
8289
if (deployResult.queryResult.records.length > 0 && deployResult.queryResult.records[0].DeployDetails.componentFailures.length > 0) {
8390
display(deployResult, this.ux);

src/commands/deploy/aura.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,14 @@ export default class AuraDeploy extends SfdxCommand {
3232
// Set this to true if your command requires a project workspace; 'requiresProject' is false by default
3333
protected static requiresProject = true;
3434

35+
private startTime: number ;
36+
37+
private endTime: number;
38+
3539
public async run(): Promise<AnyJson> {
3640

3741
this.ux.startSpinner(chalk.bold.yellowBright('Saving'));
42+
this.startTime = new Date().getTime();
3843

3944
const conn = this.org.getConnection();
4045

@@ -110,7 +115,9 @@ export default class AuraDeploy extends SfdxCommand {
110115
auraDefinitions = auraDefinitions.length > 0 ? auraDefinitions : [];
111116
try {
112117
await upsertAuraDefinition(auraDefinitions, fileBodyArray, auraDefinitionBundles[0].Id);
113-
this.ux.stopSpinner(chalk.bold.greenBright('AuraBundle Deployed Successfully ✔'));
118+
this.endTime = new Date().getTime();
119+
const executionTime = (this.endTime - this.startTime) / 1000;
120+
this.ux.stopSpinner(chalk.bold.greenBright(`AuraBundle Deployed Successfully ✔.Command execution time: ${executionTime} seconds`));
114121
} catch (exception) {
115122
this.ux.stopSpinner(chalk.bold.redBright('Aura Component Save Failed ✖'));
116123
displaylog(exception, this.ux);

src/commands/deploy/lwc.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,14 @@ export default class LWCDeploy extends SfdxCommand {
3232
// Set this to true if your command requires a project workspace; 'requiresProject' is false by default
3333
protected static requiresProject = true;
3434

35+
private startTime: number ;
36+
37+
private endTime: number;
38+
3539
public async run(): Promise<AnyJson> {
3640

3741
this.ux.startSpinner(chalk.bold.yellowBright('Saving'));
42+
this.startTime = new Date().getTime();
3843

3944
const conn = this.org.getConnection();
4045

@@ -123,7 +128,9 @@ export default class LWCDeploy extends SfdxCommand {
123128
lwcResources = lwcResources.length > 0 ? lwcResources : [];
124129
try {
125130
await upsertLWCDefinition(lwcResources, fileBodyArray, lwcBundles[0].Id);
126-
this.ux.stopSpinner(chalk.bold.greenBright('Lighnting Web Components Deployed Successfully ✔'));
131+
this.endTime = new Date().getTime();
132+
const executionTime = (this.endTime - this.startTime) / 1000;
133+
this.ux.stopSpinner(chalk.bold.greenBright(`Lighnting Web Components Deployed Successfully ✔.Command execution time: ${executionTime} seconds`));
127134
// console.log(auraDefinitionsResult);
128135
} catch (exception) {
129136
this.ux.stopSpinner(chalk.bold.redBright('Failed ✖'));

src/commands/deploy/staticresource.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,13 @@ export default class StaticResourceDeploy extends SfdxCommand {
4848
// Set this to true if your command requires a project workspace; 'requiresProject' is false by default
4949
protected static requiresProject = true;
5050

51+
private startTime: number ;
52+
53+
private endTime: number;
54+
5155
public async run(): Promise<AnyJson> {
5256
this.ux.startSpinner(chalk.bold.yellowBright("Saving"));
57+
this.startTime = new Date().getTime();
5358

5459
const conn = this.org.getConnection();
5560

@@ -125,8 +130,10 @@ export default class StaticResourceDeploy extends SfdxCommand {
125130
staticresource.Name = staticResourceName;
126131
await conn.tooling.sobject("StaticResource").create(staticresource);
127132
}
133+
this.endTime = new Date().getTime();
134+
const executionTime = (this.endTime - this.startTime) / 1000;
128135
this.ux.stopSpinner(
129-
chalk.bold.greenBright("StaticResource Deployed Successfully ✔")
136+
chalk.bold.greenBright(`StaticResource Deployed Successfully ✔.Command execution time: ${executionTime} seconds`)
130137
);
131138
} catch (e) {
132139
this.ux.stopSpinner(

0 commit comments

Comments
 (0)