Permalink
Browse files

add compile project functionality, better handles compile response

  • Loading branch information...
1 parent cbd4cf1 commit 320e39cda922ac5bc689accc92962d1efc163782 Joe Ferraro committed Aug 3, 2012
Showing with 85 additions and 17 deletions.
  1. +4 −0 Main.sublime-menu
  2. +6 −0 commands/compile_project.rb
  3. +68 −4 mavensmate.py
  4. +7 −13 support/lib/mavensmate.rb
View
@@ -24,6 +24,10 @@
{
"caption": "Clean Project",
"command": "clean_project"
+ },
+ {
+ "caption": "Compile Project",
+ "command": "compile_project"
}
]
},
@@ -0,0 +1,6 @@
+#!/usr/bin/env ruby -W0
+require File.dirname(File.dirname(__FILE__)) + "/constants.rb"
+include Constants
+ENV["MM_CURRENT_PROJECT_DIRECTORY"] = ARGV[0]
+require LIB_ROOT + "/mavensmate.rb"
+MavensMate.compile_project
View
@@ -109,7 +109,7 @@ def run(command):
temp_file_name = generate_ui("run_apex_tests", mm_project_directory())
launch_mavens_mate_window(temp_file_name)
-#deletes selected metadata
+#replaces local copy of metadata with latest server copies
class CleanProjectCommand(sublime_plugin.WindowCommand):
def run(self):
if sublime.ok_cancel_dialog("Are you sure you want to clean this project? All local (non-server) files will be deleted and your project will be refreshed from the server", "Clean"):
@@ -122,6 +122,19 @@ def run(self):
thread.start()
handle_threads(threads, self.status_panel, handle_result, 0)
+#attempts to compile the entire project
+class CompileProjectCommand(sublime_plugin.WindowCommand):
+ def run(self):
+ if sublime.ok_cancel_dialog("Are you sure you want to compile the entire project?", "Compile Project"):
+ self.status_panel = show_mm_panel(self)
+ write_to_panel(self.status_panel, 'Compiling Project\n')
+ print "------COMPILING PROJECT------"
+ threads = []
+ thread = MetadataAPICall("compile_project", "'"+mm_project_directory()+"'")
+ threads.append(thread)
+ thread.start()
+ handle_threads(threads, self.status_panel, handle_result, 0)
+
#deletes selected metadata
class DeleteMetadataCommand(sublime_plugin.WindowCommand):
def run(self, files):
@@ -213,12 +226,27 @@ def run(self):
thread.start()
handle_threads(threads, self.status_panel, handle_result, 0)
+#deploys the currently open tabs
+class CompileTabsCommand(sublime_plugin.WindowCommand):
+ def run(self):
+ #self.status_panel = show_mm_panel(self)
+ files = get_tab_file_names()
+ files_list = ', '.join(files)
+ print files_list
+ # write_to_panel(self.status_panel, 'Compiling Active Tabs\n')
+ # threads = []
+ # thread = MetadataAPICall("compile_file", "'"+active_file+"'")
+ # threads.append(thread)
+ # thread.start()
+ # handle_threads(threads, self.status_panel, handle_result, 0)
+ foo = 'bar'
+
#handles compiling to server on save
class RemoteEdit(sublime_plugin.EventListener):
def on_post_save(self, view):
active_file = get_active_file()
fileName, ext = os.path.splitext(active_file)
- valid_file_extensions = ['.page', '.component', '.cls', '.object', '.page', '.trigger']
+ valid_file_extensions = ['.page', '.component', '.cls', '.object', '.page', '.trigger', '.tab', '.layout', '.resource', '.remoteSite']
if settings.get('mm_compile_on_save') == True and is_mm_project() == True and ext in valid_file_extensions:
self.status_panel = show_mm_panel(self)
write_to_panel(self.status_panel, 'Compiling => ' + active_file + '\n')
@@ -310,7 +338,10 @@ def print_result_message(res, panel):
line_col = ""
msg = []
if type( res['messages'] ) == list:
- msg = res['messages'][0]
+ for m in res['messages']:
+ if 'problem' in m:
+ msg = m
+ break
else:
msg = res['messages']
if 'line_number' in msg:
@@ -319,7 +350,7 @@ def print_result_message(res, panel):
line_col += ', Column: '+msg['column_number']
if len(line_col) > 0:
line_col += ')'
- write_to_panel(panel, '\n[DEPLOYMENT FAILED]: ' + msg['problem'] + line_col + '\n')
+ write_to_panel(panel, '\n[DEPLOYMENT FAILED]: ' + msg['file_name'] + ': ' + msg['problem'] + line_col + '\n')
elif 'check_deploy_status_response' in res and res['check_deploy_status_response']['result']['success'] == True:
write_to_panel(panel, '\n[Deployed Successfully]' + '\n')
elif res['success'] == False and 'message' in res:
@@ -348,6 +379,39 @@ def parse_new_metadata_input(input):
else:
return input
+def get_tab_file_names():
+ from os import path
+ from operator import itemgetter
+ from datetime import datetime
+ tabs = []
+ win = sublime.active_window()
+ for vw in win.views():
+ if vw.file_name() is not None:
+ #_, tail = path.split(vw.file_name())
+ #modified = path.getmtime(vw.file_name())
+ #tabs.append((tail, vw, modified))
+ tabs.append('"'+vw.file_name()+'"')
+ else:
+ pass # leave new/untitled files (for the moment)
+ return tabs
+
+
+class GetTabsCommand(sublime_plugin.WindowCommand):
+ def run(self):
+ from os import path
+ from operator import itemgetter
+ from datetime import datetime
+ tabs = []
+ win = sublime.active_window()
+ for vw in win.views():
+ if vw.file_name() is not None:
+ _, tail = path.split(vw.file_name())
+ modified = path.getmtime(vw.file_name())
+ #tabs.append((tail, vw, modified))
+ tabs.append((tail, vw.file_name()))
+ else:
+ pass # leave new/untitled files (for the moment)
+ print tabs
@@ -296,22 +296,16 @@ def self.delete_selected_files
#compiles entire project
def self.compile_project
- validate [:internet, :mm_project]
result = nil
begin
- puts '<div id="mm_logger">'
- TextMate.call_with_progress( :title => 'MavensMate', :message => 'Compiling Project' ) do
- zip_file = MavensMate::FileFactory.copy_project_to_tmp
- client = MavensMate::Client.new
- result = client.deploy({:zip_file => zip_file, :deploy_options => "<rollbackOnError>true</rollbackOnError>"})
- end
- puts "</div>"
+ zip_file = MavensMate::FileFactory.copy_project_to_tmp
+ client = MavensMate::Client.new
+ result = client.deploy({:zip_file => zip_file, :deploy_options => "<rollbackOnError>true</rollbackOnError>"})
+ puts result.to_json
rescue Exception => e
- alert e.message
- end
- if result[:check_deploy_status_response][:result][:success] == false
- TextMate.exit_show_html(dispatch :controller => "deploy", :action => "show_compile_result", :result => result)
- end
+ res = { :success => false, :message => e.message }
+ puts res.to_json
+ end
end
#wipes local project and rewrites with server copies based on current project's package.xml, preserves svn/git

0 comments on commit 320e39c

Please sign in to comment.