From fc78179edc4404639dbed4f76974c6aab507e81e Mon Sep 17 00:00:00 2001 From: Lushang Date: Mon, 30 Mar 2020 23:32:17 +0800 Subject: [PATCH] Miscellaneous refinements --- aura.py | 5 +++-- completions.py | 3 ++- salesforce/api/metadata.py | 10 ++++++---- util.py | 17 ----------------- 4 files changed, 11 insertions(+), 24 deletions(-) diff --git a/aura.py b/aura.py index 66d35e7..f2e8a65 100644 --- a/aura.py +++ b/aura.py @@ -145,7 +145,6 @@ def is_visible(self): class RetrieveLightningFromServer(sublime_plugin.WindowCommand): def __init__(self, *args, **kwargs): super(RetrieveLightningFromServer, self).__init__(*args, **kwargs) - self.settings = context.get_settings() def run(self, dirs): message = "Are you sure you really want to continue refreshing" @@ -157,6 +156,7 @@ def run(self, dirs): ) def is_visible(self, dirs): + self.settings = context.get_settings() self.types = {} if len(dirs) == 0: return False @@ -196,7 +196,8 @@ def __init__(self, *args, **kwargs): super(DestructLightningFromServer, self).__init__(*args, **kwargs) def run(self, dirs): - if sublime.ok_cancel_dialog("Confirm to continue?"): + if sublime.ok_cancel_dialog("This will Delete the whole folder both from the server and local!" + + " Confirm to continue?"): processor.handle_destructive_files(dirs, ignore_folder=False) def is_visible(self, dirs): diff --git a/completions.py b/completions.py index 67e5c21..d16bed9 100644 --- a/completions.py +++ b/completions.py @@ -659,7 +659,8 @@ def on_query_completions(self, view, prefix, locations): meta_type = None else: is_lightning = True if file_name.split(".")[-1] in ["app", "cmp", "evt", "html", "js"] else False - meta_type = util.get_meta_type(file_name) + attributes = util.get_file_attributes(file_name) + meta_type = attributes["metadata_folder"] # Get tag definition of Visualforce page or Lightning aura component or Lightning Web component tag_defs = [] diff --git a/salesforce/api/metadata.py b/salesforce/api/metadata.py index a201f93..7363918 100644 --- a/salesforce/api/metadata.py +++ b/salesforce/api/metadata.py @@ -18,6 +18,7 @@ class MetadataApi: def __init__(self, settings, **kwargs): self.settings = settings self.api_version = settings["api_version"] + self.deploy_options = settings["deploy_options"] self.soap = SOAP(settings) self.session = None self.result = None @@ -550,14 +551,15 @@ def deploy(self, base64_zip, test_classes=[]): start_time = datetime.datetime.now() # Populate the soap_body with actual options - deploy_options = self.settings["deploy_options"] - + # move the deploy options in to class attributes from better manipulate + # deploy_options = self.settings["deploy_options"] + # If just checkOnly, output VALIDATE, otherwise, output DEPLOY - deploy_or_validate = "validate" if deploy_options["checkOnly"] else "deploy" + deploy_or_validate = "validate" if self.deploy_options["checkOnly"] else "deploy" # [sf:deploy] Printer.get('log').write_start().write("[sf:%s] Start request for a deploy..." % deploy_or_validate) - options = deploy_options + options = self.deploy_options options["zipfile"] = base64_zip # If testLevel is Run Specified Test, diff --git a/util.py b/util.py index dd09c0d..44cfd94 100644 --- a/util.py +++ b/util.py @@ -3751,20 +3751,3 @@ def convert_csv_to_json(csvfile, xmlNodes): os.remove(tempjson) return rjson - - -def get_meta_type(file_name): - """ - Get Metadata type from file name - return: aura/lwc/classes/objects etc. - """ - paths = [] - path, file_name = os.path.split(file_name) - while os.path.isdir(path): - path, crr_dir = os.path.split(path) - if crr_dir == 'src': - break - paths.append(crr_dir) - - # return the sub-directory of src, that is the meta type - return paths[-1] \ No newline at end of file