Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/lushang/haoide
Browse files Browse the repository at this point in the history
  • Loading branch information
lushang committed Mar 28, 2022
2 parents c2a8205 + 717dd70 commit 0f55222
Show file tree
Hide file tree
Showing 49 changed files with 8,828 additions and 7,657 deletions.
4,526 changes: 2,290 additions & 2,236 deletions HISTORY.rst

Large diffs are not rendered by default.

19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Sublime IDE for Salesforce
This plugin supports [Sublime Text 3](http://www.sublimetext.com/3) for windows and OSX, not tested for Linux.
This plugin supports [Sublime Text 3](http://www.sublimetext.com/3) for windows and OSX, has not enough testing for Linux yet.

All of my motivation on this plugin come from your star, if you think this plugin is helpful in your daily work, please **star** this plugin.
All of our motivation on this plugin come from your star, if you think this plugin is helpful in your daily work, please **star** this plugin.

# Installation

Expand All @@ -14,7 +14,7 @@ Or, You can follow the step-by-step [instruction](https://meighanrockssf.wordpre
# Project Configuration
After you have installed this plugin successfully, you can follow <a href="/docs/project.md" target="_blank">Project Configuration</a> to configure your own project.

If you don't want to keep your user credential information in the plugin , you just need to do it as below format, plugin will lanuch the browser to start OAuth2 Login process,
If you don't want to keep your user credential information in the plugin , you just need to do it as below format, plugin will launch the browser to start OAuth2 Login process,
```javascript
"projects": {
"pro-sublime": {
Expand Down Expand Up @@ -43,15 +43,16 @@ If you don't want to keep your user credential information in the plugin , you j
* <a href="/docs/debug.md" target="_blank">Debug and Test</a>
* <a href="/docs/retrieve.md" target="_blank">Retrieve</a>
* <a href="/docs/deploy.md" target="_blank">Deploy</a>
* <a href="https://github.com/xjsender/SublimeApexScreenshot/raw/master/LightingDevelopment.gif" target="_blank">Lightning Aura Component Development</a>
* <a href="/docs/lwc.md" target="_blank">Lightning Web Component Development</a>
* <a href="/docs/staticresource.md" target="_blank">Static Resource Bundle</a>
* <a href="/docs/export.md" target="_blank">Export CSV</a>
* <a href="/docs/utilities.md" target="_blank">Salesforce Utilities</a>
* <a href="/docs/json2apex.md" target="_blank">Convert JSON to Apex</a>
* <a href="/docs/rest.md" target="_blank">REST Test</a>
* <a href="/docs/rest.md" target="_blank">REST API Support</a>
* <a href="/docs/dataloader.md" target="_blank">Data Loader</a>
* <a href="/docs/document.md" target="_blank">Document Quick Reference</a>
* <a href="/docs/plugin.md" target="_blank">Plugin Operation</a>
* <a href="https://github.com/xjsender/SublimeApexScreenshot/raw/master/LightingDevelopment.gif" target="_blank">Lighting Development</a>
* <a href="https://raw.githubusercontent.com/xjsender/SublimeApexScreenshot/master/Completions.gif" target="_blank">Completions Demo</a>
* <a href="http://docs.python-requests.org/en/latest/user/advanced/#proxies" target="_blank">Request Proxies</a>

Expand All @@ -63,6 +64,12 @@ If you don't want to keep your user credential information in the plugin , you j
> - [Salesforce oAuth2](https://github.com/neworganizing/salesforce-oauth2)
> - [SalesforceXyTools](https://github.com/exiahuang/SalesforceXyTools)
# Feedback & Contribution
Feel free to open issues, but you should refer to the <a href="/docs/issue.md" target="_blank">Raise Issue</a> before
reporting any bug.

well welcome to any contribution, open an issue for discussion before draft you code.

# Q&A
+ ``Refresh Package`` vs ``Update Project``
* ``Refresh Package`` can update the project by the ``package.xml`` in the project folder or ``project/src`` folder
Expand All @@ -77,7 +84,7 @@ If you don't want to keep your user credential information in the plugin , you j
* ``Deploy to Server`` is achieved by ``Metadata API`` tech, which is usually used to develop none-apex in sandbox, deploy any components into different org or production

+ What's the usage of ``Update Project Pattern`` command?
* Everytime when you udpate the ``file_exclude_patterns`` or ``folder_exclude_patterns``, you must execute ``Update Project Pattern`` command to ensure it is working.
* Everytime when you update the ``file_exclude_patterns`` or ``folder_exclude_patterns``, you must execute ``Update Project Pattern`` command to ensure it is working.
* Everytime when the default project doesn't appeared in the sidebar panel, you an use this command to show the default project.

+ If you failed to deploy package after release 3.3.7
Expand Down
131 changes: 72 additions & 59 deletions aura.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,22 @@ def run(self):
def is_enabled(self):
self.settings = context.get_settings()
metadata = util.get_described_metadata(self.settings)
if not metadata:
if not metadata:
return False

return True


class DeployLightingToServer(sublime_plugin.WindowCommand):
class DeployLightningToServer(sublime_plugin.WindowCommand):
def __init__(self, *args, **kwargs):
super(DeployLightingToServer, self).__init__(*args, **kwargs)
super(DeployLightningToServer, self).__init__(*args, **kwargs)
self.meta_type = ''

def run(self, dirs, switch_project=True, source_org=None, element=None, update_meta=False):
if switch_project:
return self.window.run_command("switch_project", {
"callback_options": {
"callback_command": "deploy_lighting_to_server",
"callback_command": "deploy_lightning_to_server",
"args": {
"switch_project": False,
"source_org": self.settings["default_project_name"],
Expand All @@ -47,11 +48,11 @@ def run(self, dirs, switch_project=True, source_org=None, element=None, update_m
}
})

base64_package = util.build_aura_package(dirs, meta_type=element)
base64_package = util.build_lightning_package(dirs, meta_type=self.meta_type)
processor.handle_deploy_thread(
base64_package,
source_org=source_org,
element=element,
base64_package,
source_org=source_org,
element=element,
update_meta=update_meta
)

Expand All @@ -62,18 +63,19 @@ def is_visible(self, dirs, switch_project=True):
self.settings = context.get_settings()
for _dir in dirs:
attributes = util.get_file_attributes(_dir)
metadata_folder = attributes["metadata_folder"]
if metadata_folder not in ["aura", "lwc"]:
meta_folder = attributes["metadata_folder"]
if meta_folder not in ["aura", "lwc"]:
return False
self.meta_type = 'AuraDefinitionBundle' if meta_folder == 'aura' else 'LightningComponentBundle'
if self.settings["default_project_name"] not in _dir:
return False

return True


class PreviewLightingAppInServer(sublime_plugin.WindowCommand):
class PreviewLightningAppInServer(sublime_plugin.WindowCommand):
def __init__(self, *args, **kwargs):
super(PreviewLightingAppInServer, self).__init__(*args, **kwargs)
super(PreviewLightningAppInServer, self).__init__(*args, **kwargs)

def run(self, app_name=None):
if app_name:
Expand Down Expand Up @@ -109,9 +111,9 @@ def preview_app(self, app_name):
def is_enabled(self):
self.settings = context.get_settings()
metadata = util.get_described_metadata(self.settings)
if not metadata:
if not metadata:
return False

self.namespace = metadata["organizationNamespace"]
if not self.namespace:
self.namespace = 'c'
Expand All @@ -121,12 +123,12 @@ def is_enabled(self):

class PreviewThisAppInServer(sublime_plugin.TextCommand):
def run(self, edit):
self.view.window().run_command('preview_lighting_app_in_server', {
self.view.window().run_command('preview_lightning_app_in_server', {
"app_name": self.app_name
})

def is_enabled(self):
if not self.view.file_name():
if not self.view.file_name():
return False

attrs = util.get_file_attributes(self.view.file_name())
Expand All @@ -140,70 +142,81 @@ def is_visible(self):
return self.is_enabled()


class RetrieveLightingFromServer(sublime_plugin.WindowCommand):
class RetrieveLightningFromServer(sublime_plugin.WindowCommand):
def __init__(self, *args, **kwargs):
super(RetrieveLightingFromServer, self).__init__(*args, **kwargs)
super(RetrieveLightningFromServer, self).__init__(*args, **kwargs)

def run(self, dirs):
message = "Are you sure you really want to continue refreshing"
if sublime.ok_cancel_dialog(message, "Confirm?"):
processor.handle_retrieve_package(
self.types,
self.settings["workspace"],
self.types,
self.settings["workspace"],
ignore_package_xml=True
)

def is_visible(self, dirs):
if len(dirs) == 0: return False
self.settings = context.get_settings()
self.types = {}
if len(dirs) == 0:
return False
for _dir in dirs:
if os.path.isfile(_dir): continue
if os.path.isfile(_dir):
continue
base, _name = os.path.split(_dir)
base, _folder = os.path.split(base)

# Check Metadata Type
if _folder != "aura": continue
if _folder not in ["aura", "lwc"]:
continue

# Check Project Name
pn = self.settings["default_project_name"]
if pn not in _dir: continue
if pn not in _dir:
continue

if "AuraDefinitionBundle" in self.types:
self.types["AuraDefinitionBundle"].append(_name)
else:
elif "LightningComponentBundle" in self.types:
self.types["LightningComponentBundle"].append(_name)
elif _folder == 'aura':
self.types["AuraDefinitionBundle"] = [_name]

elif _folder == 'lwc':
self.types["LightningComponentBundle"] = [_name]

# Check whether any aura components are chosen
if not self.types: return False
if not self.types:
return False

return True


class DestructLightingFromServer(sublime_plugin.WindowCommand):
class DestructLightningFromServer(sublime_plugin.WindowCommand):
def __init__(self, *args, **kwargs):
super(DestructLightingFromServer, self).__init__(*args, **kwargs)
super(DestructLightningFromServer, self).__init__(*args, **kwargs)

def run(self, dirs):
if sublime.ok_cancel_dialog("Confirm to continue?"):
_, bundle_name = os.path.split(dirs[0])
if sublime.ok_cancel_dialog("This will Delete %s !" % bundle_name + " Confirm to continue?"):
processor.handle_destructive_files(dirs, ignore_folder=False)

def is_visible(self, dirs):
if len(dirs) == 0: return False
if len(dirs) == 0:
return False
self.settings = context.get_settings()
for _dir in dirs:
attributes = util.get_file_attributes(_dir)
if attributes["metadata_folder"] != "aura":
if attributes["metadata_folder"] not in ["aura", "lwc"]:
return False
if not util.check_enabled(_dir, check_cache=False):
if not util.check_enabled(_dir, check_cache=False):
return False

return True


class CreateLightingElement(sublime_plugin.WindowCommand):
class CreateLightningElement(sublime_plugin.WindowCommand):
def __init__(self, *args, **kwargs):
super(CreateLightingElement, self).__init__(*args, **kwargs)
super(CreateLightningElement, self).__init__(*args, **kwargs)

def run(self, dirs, element=""):
""" element: Component, Controller, Helper, Style, Documentation, Render
Expand All @@ -213,16 +226,16 @@ def run(self, dirs, element=""):
templates = util.load_templates()
template = templates.get("AuraElement").get(element)
settings = context.get_settings()
tempaltes_path = os.path.join(settings["workspace"],
".templates", template["directory"])
with open(tempaltes_path) as fp:
templates_path = os.path.join(settings["workspace"],
".templates", template["directory"])
with open(templates_path) as fp:
body = fp.read()

# JS Component is different with others
extension = template["extension"]
element_name = "%s%s%s" % (
self.aura_name,
element if extension == ".js" else "",
element if extension == ".js" else "",
extension
)

Expand All @@ -242,7 +255,7 @@ def run(self, dirs, element=""):
self.window.run_command("refresh_folder_list")

# Deploy Aura to server
self.window.run_command("deploy_lighting_to_server", {
self.window.run_command("deploy_lightning_to_server", {
"dirs": [self._dir],
"switch_project": False,
"element": element,
Expand All @@ -264,36 +277,36 @@ def is_visible(self, dirs, element=""):
return False
self.aura_name = attributes["name"]

# Check lighting type
lighting_extensions = []
# Check lightning type
lightning_extensions = []
for dirpath, dirnames, filenames in os.walk(self._dir):
for filename in filenames:
extension = filename[filename.find("."):]
lighting_extensions.append(extension)
lightning_extensions.append(extension)

# Just Component and Application can have child elements
if ".cmp" in lighting_extensions or ".app" in lighting_extensions:
if ".cmp" in lightning_extensions or ".app" in lightning_extensions:
return True

return False


class CreateLightingDefinition(sublime_plugin.WindowCommand):
class CreateLightningDefinition(sublime_plugin.WindowCommand):
def __init__(self, *args, **kwargs):
super(CreateLightingDefinition, self).__init__(*args, **kwargs)
super(CreateLightningDefinition, self).__init__(*args, **kwargs)

def run(self, _type=""):
self._type = _type
self.window.show_input_panel("Please Input %s Name: " % _type,
"", self.on_input, None, None)
self.window.show_input_panel("Please Input %s Name: " % _type,
"", self.on_input, None, None)

def on_input(self, lightning_name):
# Create component to local according to user input
if not re.match('^[a-zA-Z]+\\w+$', lightning_name):
message = 'Invalid format, do you want to try again?'
if not sublime.ok_cancel_dialog(message): return
self.window.show_input_panel("Please Input %s Name: " % self._type,
"", self.on_input, None, None)
self.window.show_input_panel("Please Input %s Name: " % self._type,
"", self.on_input, None, None)
return

# Get settings
Expand All @@ -306,20 +319,20 @@ def on_input(self, lightning_name):
with open(os.path.join(workspace, ".templates", template["directory"])) as fp:
body = fp.read()

# Build dir for new lighting component
# Build dir for new lightning component
component_dir = os.path.join(workspace, "src", "aura", lightning_name)
if not os.path.exists(component_dir):
os.makedirs(component_dir)
else:
message = "%s is already exist, do you want to try again?" % lightning_name
if not sublime.ok_cancel_dialog(message, "Try Again?"): return
self.window.show_input_panel("Please Input Lighting Name: ",
"", self.on_input, None, None)
self.window.show_input_panel("Please Input Lightning Name: ",
"", self.on_input, None, None)
return

lightning_file = os.path.join(component_dir, lightning_name+template["extension"])

# Create Aura lighting file
lightning_file = os.path.join(component_dir, lightning_name + template["extension"])

# Create Aura lightning file
with open(lightning_file, "w") as fp:
fp.write(body)

Expand All @@ -329,7 +342,7 @@ def on_input(self, lightning_name):
window.run_command("refresh_folder_list")

# Deploy Aura to server
self.window.run_command("deploy_lighting_to_server", {
self.window.run_command("deploy_lightning_to_server", {
"dirs": [component_dir],
"switch_project": False,
"element": self._type,
Expand Down
Loading

0 comments on commit 0f55222

Please sign in to comment.