Skip to content

Commit cc38fcf

Browse files
author
Mohith Shrivastava
committed
support static resource deploy
1 parent 5ca4951 commit cc38fcf

File tree

4 files changed

+56
-36
lines changed

4 files changed

+56
-36
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
# Change Log
22
All notable changes to the "dx-code-companion" extension will be documented in this file.
33

4+
### 0.3.7
5+
1.Added support for saving static resource files to server via tooling api.
6+
47
### 0.3.6
58
1.To manage settings you dont need to edit the settings.json and instead has UI
6-
2.Security path via npm audit
9+
2.Security patches (discovered via npm audit)
710

811
### 0.3.3
912

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ To open command pallete and look for all CCDX Commands use below .
111111

112112
# Release Notes
113113

114+
### 0.3.7
115+
1.Now you can directly edit the static resource file and save to the server.Note that your folders or files should be within folder named "staticresources".If you are building a vf app using vue or React,you can keep your files in folder named staticresources and edit the app and save the file.
116+
114117
### 0.3.6
115118
1.To manage settings you dont need to edit the settings.json and instead has UI
116119
2.Security path via npm audit

src/services/deploy.ts

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export class DeploySource {
3737
}
3838

3939
public static deployToSFDC(textDocument: vscode.TextDocument) {
40-
if(this.supportedFileForDeploy()) {
40+
if(this. supportedFileForDeploy()) {
4141
// The authorization creates sfdx-project.json files and this extension supports only auth done using sfdx cli
4242
if(this.isProjectAuthroizedToSFDC()) {
4343
if(vscode.window.activeTextEditor) {
@@ -175,22 +175,27 @@ export class DeploySource {
175175
private static supportedFileForDeploy() : boolean {
176176
let fileSupported = false;
177177
if(vscode.window.activeTextEditor) {
178-
//At this point only few file types are supported for auto save
179-
const supportedFileTypes = ['trigger','cls','cmp','evt','design','tokens','page','svg','auradoc','component','intf','app'];
180178
const filePath = vscode.window.activeTextEditor.document.uri.fsPath;
181-
const pathAsArray = filePath.split('/');
182-
const lastparam = pathAsArray[pathAsArray.length - 1];
183-
const fileExtension = lastparam.substring(lastparam.lastIndexOf('.') + 1);
184-
const directory = path.basename(path.dirname(path.dirname(filePath)));
185-
if(fileExtension === 'js' || fileExtension === 'css' || fileExtension === 'html') {
186-
// check for immediate directory
187-
if(directory === 'lwc' || directory === 'aura') {
179+
// Check if this is a static resource
180+
if(filePath.indexOf('/staticresources/') !== -1) {
181+
fileSupported = true;
182+
} else {
183+
//At this point only few file types are supported for auto save
184+
const supportedFileTypes = ['trigger','cls','cmp','evt','design','tokens','page','svg','auradoc','component','intf','app'];
185+
const pathAsArray = filePath.split('/');
186+
const lastparam = pathAsArray[pathAsArray.length - 1];
187+
const fileExtension = lastparam.substring(lastparam.lastIndexOf('.') + 1);
188+
const directory = path.basename(path.dirname(path.dirname(filePath)));
189+
if(fileExtension === 'js' || fileExtension === 'css' || fileExtension === 'html') {
190+
// check for immediate directory
191+
if(directory === 'lwc' || directory === 'aura') {
192+
fileSupported = true;
193+
}
194+
}
195+
if(supportedFileTypes.indexOf(fileExtension) !== -1 ){
188196
fileSupported = true;
189197
}
190198
}
191-
if(supportedFileTypes.indexOf(fileExtension) !== -1 ){
192-
fileSupported = true;
193-
}
194199
}
195200
return fileSupported;
196201
}

src/services/findMetadataType.ts

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,46 @@ export class Metadata {
77

88
protected filepath: string;
99
protected directory: string;
10+
protected isstaticresource : boolean;
1011

1112
constructor(filepath: string) {
1213
this.filepath = filepath;
1314
this.directory = path.basename(path.dirname(path.dirname(this.filepath)));
15+
this.isstaticresource = filepath.indexOf('/staticresources/') === -1 ? false : true;
1416
}
1517

1618
public getMetadataType(): MetadataType {
1719
const metadataType = {} as MetadataType;
18-
// const auraFiles = ['.cmp','.app','.evt','.css','.js','design','svg','tokens','intf','auradoc'];
19-
if(this.filepath.includes('.cls')){
20-
metadataType.MetadataName = 'ApexClass';
21-
metadataType.CommandName = 'apex';
22-
} else if(this.filepath.includes('.trigger')) {
23-
metadataType.MetadataName = 'ApexTrigger';
24-
metadataType.CommandName = 'trigger';
25-
} else if (this.filepath.includes('.page')){
26-
metadataType.MetadataName = 'ApexPage';
27-
metadataType.CommandName = 'vf';
28-
} else if (this.filepath.includes('.component')){
29-
metadataType.MetadataName = 'ApexComponent';
30-
metadataType.CommandName = 'vfcomponent';
31-
} else if (this.directory === 'aura'){
32-
metadataType.MetadataName = 'AuraDefinition';
33-
metadataType.CommandName = 'aura';
34-
} else if (this.directory === 'lwc'){
35-
metadataType.MetadataName = 'LightningComponent';
36-
metadataType.CommandName = 'lwc';
20+
// check for static Resource
21+
if(this.isstaticresource) {
22+
metadataType.MetadataName = 'StaticResource';
23+
metadataType.CommandName = 'staticresource';
3724
} else {
38-
// Modify this to add support for other Metadata Types
39-
metadataType.MetadataName = 'unknown';
40-
metadataType.CommandName = 'unknown';
25+
// const auraFiles = ['.cmp','.app','.evt','.css','.js','design','svg','tokens','intf','auradoc'];
26+
if(this.filepath.includes('.cls')){
27+
metadataType.MetadataName = 'ApexClass';
28+
metadataType.CommandName = 'apex';
29+
} else if(this.filepath.includes('.trigger')) {
30+
metadataType.MetadataName = 'ApexTrigger';
31+
metadataType.CommandName = 'trigger';
32+
} else if (this.filepath.includes('.page')){
33+
metadataType.MetadataName = 'ApexPage';
34+
metadataType.CommandName = 'vf';
35+
} else if (this.filepath.includes('.component')){
36+
metadataType.MetadataName = 'ApexComponent';
37+
metadataType.CommandName = 'vfcomponent';
38+
} else if (this.directory === 'aura'){
39+
metadataType.MetadataName = 'AuraDefinition';
40+
metadataType.CommandName = 'aura';
41+
} else if (this.directory === 'lwc'){
42+
metadataType.MetadataName = 'LightningComponent';
43+
metadataType.CommandName = 'lwc';
44+
}
45+
else {
46+
// Modify this to add support for other Metadata Types
47+
metadataType.MetadataName = 'unknown';
48+
metadataType.CommandName = 'unknown';
49+
}
4150
}
4251
return metadataType;
4352
}

0 commit comments

Comments
 (0)