Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

deploy to server functionality

  • Loading branch information...
commit 419c98e162fde0e615175f742d68b3fcb96ac0d2 1 parent f75c721
Joe Ferraro authored
View
7 commands/deploy_to_server.rb
@@ -0,0 +1,7 @@
+#!/usr/bin/env ruby -W0
+require File.dirname(File.dirname(__FILE__)) + "/constants.rb"
+include Constants
+require SUPPORT + "/environment.rb"
+require CONTROLLERS_ROOT + "/deploy_controller.rb"
+ENV["MM_CURRENT_PROJECT_DIRECTORY"] = ARGV[0]
+dispatch :controller => "deploy", :action => "index"
View
9 mavensmate.py
@@ -88,6 +88,13 @@ def run(command):
temp_file_name = generate_ui("new_project", mm_workspace())
launch_mavens_mate_window(temp_file_name)
+#displays deploy dialog
+class DeployToServerCommand(sublime_plugin.ApplicationCommand):
+ def run(command):
+ start_local_server()
+ temp_file_name = generate_ui("deploy_to_server", mm_project_directory())
+ launch_mavens_mate_window(temp_file_name)
+
#displays new project dialog
class CheckoutProjectCommand(sublime_plugin.ApplicationCommand):
def run(command):
@@ -282,7 +289,7 @@ def run(self):
msg_string = msg_string.replace(":null", "None")
msg_string = msg_string.replace("namespace\"None", "namespace\":None")
msg_string = msg_string.replace("\\n", "\\\n")
- #print "result is: " + msg_string
+ print "result is: " + msg_string
res = None
try:
res = ast.literal_eval(msg_string)
View
68 support/app/controllers/deploy_controller.rb
@@ -1,9 +1,9 @@
# encoding: utf-8
-require ENV['TM_BUNDLE_SUPPORT'] + '/lib/mavensmate.rb'
-require ENV['TM_BUNDLE_SUPPORT'] + '/lib/factory.rb'
-require ENV['TM_BUNDLE_SUPPORT'] + '/lib/metadata_helper.rb'
-require ENV['TM_BUNDLE_SUPPORT'] + '/lib/object.rb'
-require ENV['TM_BUNDLE_SUPPORT'] + '/lib/util.rb'
+require SUPPORT + '/lib/mavensmate.rb'
+require SUPPORT + '/lib/factory.rb'
+require SUPPORT + '/lib/metadata_helper.rb'
+require SUPPORT + '/lib/object.rb'
+require SUPPORT + '/lib/util.rb'
class DeployController < ApplicationController
include MetadataHelper
@@ -11,16 +11,16 @@ class DeployController < ApplicationController
layout "base", :only => [:index, :index_new, :show_compile_result]
def index
- if File.not.exist? "#{ENV['TM_PROJECT_DIRECTORY']}/config/.org_metadata"
- MavensMate.build_index
- else
- confirmed = TextMate::UI.request_confirmation(
- :title => "MavensMate",
- :prompt => "Would you like to refresh the local index of your Salesforce.com org's metadata?",
- :button1 => "Refresh",
- :button2 => "No")
- end
-
+ # if File.not.exist? "#{ENV['MM_CURRENT_PROJECT_DIRECTORY']}/config/.org_metadata"
+ # MavensMate.build_index
+ # else
+ # confirmed = TextMate::UI.request_confirmation(
+ # :title => "MavensMate",
+ # :prompt => "Would you like to refresh the local index of your Salesforce.com org's metadata?",
+ # :button1 => "Refresh",
+ # :button2 => "No")
+ # end
+ #MavensMate.build_index
connections = []
begin
pconfig = MavensMate.get_project_config
@@ -38,20 +38,20 @@ def index
end
changesets = []
- if File.directory?("#{ENV['TM_PROJECT_DIRECTORY']}/changesets")
- Dir.foreach("#{ENV['TM_PROJECT_DIRECTORY']}/changesets") do |c|
- next if c == "." or c == ".."
- changesets.push(c)
- end
- end
+ # if File.directory?("#{ENV['MM_CURRENT_PROJECT_DIRECTORY']}/changesets")
+ # Dir.foreach("#{ENV['MM_CURRENT_PROJECT_DIRECTORY']}/changesets") do |c|
+ # next if c == "." or c == ".."
+ # changesets.push(c)
+ # end
+ # end
- MavensMate.build_index if confirmed
- meta_array = eval(File.read("#{ENV['TM_PROJECT_DIRECTORY']}/config/.org_metadata")) #=> comprehensive list of server metadata
- render "_deploy", :locals => { :meta_array => meta_array, :child_metadata_definition => CHILD_META_DICTIONARY, :connections => connections, :changesets => changesets }
+ #MavensMate.build_index if confirmed
+ #meta_array = eval(File.read("#{ENV['MM_CURRENT_PROJECT_DIRECTORY']}/config/.org_metadata")) #=> comprehensive list of server metadata
+ render "_deploy", :locals => { :child_metadata_definition => CHILD_META_DICTIONARY, :connections => connections, :changesets => changesets }
end
def index_new
- # if File.not.exist? "#{ENV['TM_PROJECT_DIRECTORY']}/config/.org_metadata"
+ # if File.not.exist? "#{ENV['MM_CURRENT_PROJECT_DIRECTORY']}/config/.org_metadata"
# MavensMate.build_index
# else
# confirmed = TextMate::UI.request_confirmation(
@@ -80,15 +80,15 @@ def index_new
end
changesets = []
- if File.directory?("#{ENV['TM_PROJECT_DIRECTORY']}/changesets")
- Dir.foreach("#{ENV['TM_PROJECT_DIRECTORY']}/changesets") do |c|
+ if File.directory?("#{ENV['MM_CURRENT_PROJECT_DIRECTORY']}/changesets")
+ Dir.foreach("#{ENV['MM_CURRENT_PROJECT_DIRECTORY']}/changesets") do |c|
next if c == "." or c == ".."
changesets.push(c)
end
end
MavensMate.build_index if confirmed
- meta_array = eval(File.read("#{ENV['TM_PROJECT_DIRECTORY']}/config/.org_metadata")) #=> comprehensive list of server metadata
+ meta_array = eval(File.read("#{ENV['MM_CURRENT_PROJECT_DIRECTORY']}/config/.org_metadata")) #=> comprehensive list of server metadata
render "_deploy_compare", :locals => { :meta_array => meta_array, :child_metadata_definition => CHILD_META_DICTIONARY, :connections => connections, :changesets => changesets }
end
@@ -113,16 +113,16 @@ def deploy_metadata
is_check_only = params[:check_only]
result = MavensMate.deploy_to_server(params)
result = MavensMate::Util.parse_deploy_response(result)
- `osascript '#{ENV['TM_BUNDLE_SUPPORT']}/osx/growl.scpt' 'Deploy complete'`
+ `osascript '#{SUPPORT}/osx/growl.scpt' 'Deploy complete'`
require 'erb'
- template = ERB.new File.new("#{ENV['TM_BUNDLE_SUPPORT']}/app/views/deploy/_async_deploy_result.html.erb").read, nil, "-"
+ template = ERB.new File.new("#{SUPPORT}/app/views/deploy/_async_deploy_result.html.erb").read, nil, "-"
erb = template.result(binding)
- src = File.new("#{ENV['TM_PROJECT_DIRECTORY']}/config/.async_deploy_result.html", "w")
+ src = File.new("#{ENV['MM_CURRENT_PROJECT_DIRECTORY']}/config/.async_deploy_result.html", "w")
src.puts(erb)
src.close
MavensMate.close_deploy_window
- `open "#{ENV['TM_PROJECT_DIRECTORY']}/config/.async_deploy_result.html"`
+ `open "#{ENV['MM_CURRENT_PROJECT_DIRECTORY']}/config/.async_deploy_result.html"`
rescue Exception => e
TextMate::UI.alert(:warning, "MavensMate", e.message + "\n" + e.backtrace.join("\n"))
end
@@ -135,7 +135,7 @@ def deploy_metadata
result = MavensMate.deploy_to_server(params)
result = MavensMate::Util.parse_deploy_response(result)
render "_deploy_result", :locals => { :result => result, :is_check_only => params[:check_only] }
- `osascript '#{ENV['TM_BUNDLE_SUPPORT']}/osx/growl.scpt' 'Deploy complete'`
+ `osascript '#{SUPPORT}/osx/growl.scpt' 'Deploy complete'`
rescue Exception => e
TextMate::UI.alert(:warning, "MavensMate", e.message + "\n" + e.backtrace.join("\n"))
end
@@ -151,7 +151,7 @@ def show_compile_result
file_name = message[:file_name]
fns = message[:file_name].split("/")
file_name = fns[fns.length - 1]
- full_path = "#{ENV['TM_PROJECT_DIRECTORY']}/src/#{message[:file_name]}"
+ full_path = "#{ENV['MM_CURRENT_PROJECT_DIRECTORY']}/src/#{message[:file_name]}"
full_path.gsub!(/unpackaged\//, '')
TextMate.go_to(:file => full_path, :line => message[:line_number], :column => message[:column_number])
rescue
View
231 support/app/views/deploy/_deploy.html.erb
@@ -100,15 +100,9 @@
<label for="cname" style="font-weight:bold;">Changeset Name</label>
<input class="xlarge" size="100" type="text" id="cname">
</div> -->
- <div class="clearfix">
- <label>
- <input type="checkbox" id="set_and_forget" style="margin:0px;width:32px;"/>
- <div>Set and Forget</div>
- </label>
- </div>
- <div id="deploy_info" style="display:none;" class="alert-message block-message info">
+<!-- <div id="deploy_info" style="display:none;" class="alert-message block-message info">
<p><strong>This deployment will run in async mode.</strong></p>
- </div>
+ </div> -->
</fieldset>
</form>
@@ -127,15 +121,16 @@
<div id="metadata">
- <form class="form-stacked" style="padding-left:15px;margin-bottom:5px;">
+ <form class="form-stacked" style="padding-left:5px;margin-bottom:2px;">
<fieldset>
- <div class="clearfix">
+<!-- <div class="clearfix">
<label for="ptype">Package Type</label>
<select id="ptype">
<option>Custom</option>
<option>Changeset</option>
</select>
- </div>
+ </div> -->
+ <a href="javascript:void(0)" class="btn success" onclick="refresh_index()">Refresh Metadata From Server</a>
<div class="clearfix" id="changesetwrapper" style="display:none">
<label for="cset">Changeset</label>
<select id="cset">
@@ -162,7 +157,7 @@
<div id="project_wrapper">
<div id="filter">
- <input type="text" id="txtFilter" style="width:200px" />
+ <input type="text" id="txtFilter" style="width:165px" />
<a href="#" id="btnClearFilter" onclick="clearFilter();" class="btn small error" style="visibility:invisible;opacity:0;font-weight:bold;position:relative;top:1px;right:30px;padding:4px 7px 4px;">X</a>
<a href="#" id="btnSelectAll" class="btn small" style="font-weight:normal;padding:4px 7px 4px;">all</a>
<a href="#" id="btnDeselectAll" class="btn small" style="font-weight:normal;padding:4px 7px 4px;">none</a>
@@ -171,39 +166,7 @@
<div id="treewrapper">
<div id="tree">
<ul>
- <% meta_array.each do |hash| %>
- <%
- next if !hash[:children]
- next if hash[:children].size == 0
- class_name = (hash[:children] && hash[:children].size > 0) ? "folder" : ""
- %>
- <li data="level: 1, hasChildTypes: <%=hash[:hasChildTypes]%>, inFolder: <%=hash[:inFolder]%>" id="<%= hash[:key] %>" class="folder level1"><%= hash[:title] %>
- <% if hash[:children] %>
- <ul>
- <% hash[:children].each do |child| %>
- <% child_class_name = (child[:children] && child[:children].size > 0) ? "folder" : "" %>
- <li data="level: 2" id="<%= child[:key] %>" class="<%= child_class_name %> level2"><%= child[:title] %>
- <% if child[:children] && child[:children].size > 0 %>
- <ul>
- <% child[:children].each do |gchild| %>
- <li data="level: 3" class="level3"><%= gchild[:title] %>
- <% if gchild[:children] && gchild[:children].size > 0 %>
- <ul>
- <% gchild[:children].each do |ggchild| %>
- <li data="level: 4" class="level4"><%= ggchild[:title] %></li>
- <% end %>
- </ul>
- <% end %>
- </li>
- <% end %>
- </ul>
- <% end %>
- </li>
- <% end %>
- </ul>
- <% end %>
- </li>
- <% end %>
+
</ul>
</div>
<div id="info"></div>
@@ -232,12 +195,14 @@
<div class="loading_indicator"></div>
</div>
<div class="deploy_wait_description">
- Deploying to <span id="where"></span>.<br/><br/>
- Do not close or minimize this window.
+ Indexing metadata...
</div>
<script type="text/javascript">
+ var mm_cpd = '<%= ENV["MM_CURRENT_PROJECT_DIRECTORY"] %>';
+ var has_indexed_metadata = <%= File.exist? "#{ENV["MM_CURRENT_PROJECT_DIRECTORY"]}/config/.org_metadata" %>;
+
document.title = "Deploy To Server";
var child_def = {}
@@ -270,15 +235,7 @@
return "";
}
}
-
- $("#set_and_forget").click(function() {
- if (this.checked) {
- $("#deploy_info").show();
- } else {
- $("#deploy_info").hide();
- }
- });
-
+
$("#save_changeset").click(function() {
if (this.checked) {
$("#changeset_name_wrapper").show();
@@ -286,32 +243,7 @@
$("#changeset_name_wrapper").hide();
}
});
-
-
- function deploy() {
- deploy_mode = deployMode();
- if (deploy_mode == "async") {
- $("#where").html($("#un").val());
- $(".deploy_loading").fadeIn();
- $(".deploy_wait_description").fadeIn();
- }
-
- $("#result").html(
- dispatch({
- controller: "deploy",
- action: "deploy_metadata",
- un: $("#un").val(),
- pw: $("#pw").val(),
- server_url: $("#server_url").val(),
- check_only: isValidateOnly(),
- mode: deploy_mode,
- tree: get_tree(),
- package_type: $("#ptype").val(),
- changeset: $("#cset").val()
- })
- );
- }
-
+
function resizeWindowAfterResult() {
window.resizeTo(800, window.innerHeight);
window.moveTo(
@@ -321,6 +253,7 @@
}
$(function() {
+
//if dom elements is removed, we need to resize the window
$( "body" ).bind(
"DOMNodeInserted",
@@ -369,21 +302,15 @@
$('.tabs').tabs();
- $("#project_wrapper").height($(window).height() - 175)
+ $("#project_wrapper").height($(window).height() - 225)
var resizeHeight = $("#form").height();
- resizeAndCenterWindowByHeight(resizeHeight + 150);
+ resizeAndCenterWindowByHeight(resizeHeight + 250);
$(window).resize(function() {
- $("#project_wrapper").height($(window).height() - 175)
+ $("#project_wrapper").height($(window).height() - 225)
});
- //instantiate and populate metadata tree
- $("#tree").dynatree({
- persist: false,
- checkbox: true,
- selectMode: 3
- });
$.expr[':'].Contains = function(a, i, m) {
return (a.textContent || a.innerText || "").toUpperCase().indexOf(m[3].toUpperCase()) >= 0;
@@ -419,49 +346,27 @@
// fire the above change event after every letter
$(this).change();
});
-
- $("#tree").dynatree("getRoot").visit(function(node) {
- node.expand(false);
- });
- var rootNode = $("#tree").dynatree("getRoot");
-
- function filter_tree(searchTerm) {
- var regex = new RegExp(searchTerm,"i");
- rootNode.visit(function(node) { 
       
- if (node.isVisible() && node.data.title) { 
           
- // Filter currently visible non-root nodes. 
           
- nodeTitle = node.data.title;
-
- if ( nodeTitle.match(regex) ) {
- // Make sure we and all our parents are visible 
               
- node.visitParents(function(node) { 
                   
- $(node.li).show(); 
                   
- return (node.parent != null); 
               
- }, true);
-             // Terminate the traversal of this branch since the node matches
- return 'skip';
- } else {
- $(node.li).hide();
- }
-
-
- // if (nodeTitle.indexOf(searchTerm) >= 0 || nodeTitleLower.indexOf(searchTerm) >= 0) { 
               
- // // Make sure we and all our parents are visible 
               
- // node.visitParents(function(node) { 
                   
- // $(node.li).show(); 
                   
- // return (node.parent != null); 
               
- // }, true);
- //             // Terminate the traversal of this branch since the node matches
- // return 'skip'; 
           
- // } else { 
               
- // // Hide the node. 
               
- // $(node.li).hide(); 
           
- // }
- }
- });
- }
+ index_org(!has_indexed_metadata);
});
+
+ function filter_tree(searchTerm) {
+ var regex = new RegExp(searchTerm,"i");
+ rootNode.visit(function(node) {
+ if (node.isVisible() && node.data.title) {
+ nodeTitle = node.data.title;
+ if ( nodeTitle.match(regex) ) {
+ node.visitParents(function(node) {
+ $(node.li).show();
+ return (node.parent != null);
+ }, true);
+ return 'skip';
+ } else {
+ $(node.li).hide();
+ }
+ }
+ });
+ }
function expandAll() {
$("#tree").dynatree("getRoot").visit(function(node){
@@ -508,5 +413,65 @@
}
});
return false;
- });
+ });
+
+ function showBlanket() { $('.deploy_loading').fadeIn(); }
+
+ function hideBlanket() { $('.deploy_loading').hide(); }
+
+ var rootNode;
+
+ function index_org(refresh) {
+ console.log('indexing org')
+ console.log(refresh)
+ $.ajax({
+ type: "GET",
+ url: "http://127.0.0.1:7777/metadata/index",
+ data: {
+ mm_current_project_directory: mm_cpd,
+ do_refresh: refresh
+ },
+ beforeSend: function() { showBlanket(); },
+ complete: function(data){
+ console.log(data)
+ $("#tree").dynatree("destroy")
+ $("#tree ul").html(data.responseText);
+ $("#tree").dynatree({
+ persist: false,
+ checkbox: true,
+ selectMode: 3
+ });
+ $("#tree").dynatree("getRoot").visit(function(node) {
+ node.expand(false);
+ });
+ rootNode = $("#tree").dynatree("getRoot");
+ hideBlanket();
+ }
+ });
+ }
+
+ function refresh_index() {
+ index_org(true);
+ }
+
+ function deploy() {
+ $.ajax({
+ type: "POST",
+ url: "http://127.0.0.1:7777/deploy",
+ data: {
+ un: $("#un").val(),
+ pw: $("#pw").val(),
+ server_url: $("#server_url").val(),
+ check_only: isValidateOnly(),
+ tree: get_tree(),
+ mm_current_project_directory: mm_cpd
+ },
+ beforeSend: function() { showBlanket(); },
+ complete: function(data){
+ console.log(data)
+ $("#result").html(data.responseText);
+ hideBlanket();
+ }
+ });
+ }
</script>
View
33 support/app/views/deploy/_metadata_tree.html.erb
@@ -0,0 +1,33 @@
+<% meta_array.each do |hash| %>
+ <%
+ next if !hash[:children]
+ next if hash[:children].size == 0
+ class_name = (hash[:children] && hash[:children].size > 0) ? "folder" : ""
+ %>
+ <li data="level: 1, hasChildTypes: <%=hash[:hasChildTypes]%>, inFolder: <%=hash[:inFolder]%>" id="<%= hash[:key] %>" class="folder level1"><%= hash[:title] %>
+ <% if hash[:children] %>
+ <ul>
+ <% hash[:children].each do |child| %>
+ <% child_class_name = (child[:children] && child[:children].size > 0) ? "folder" : "" %>
+ <li data="level: 2" id="<%= child[:key] %>" class="<%= child_class_name %> level2"><%= child[:title] %>
+ <% if child[:children] && child[:children].size > 0 %>
+ <ul>
+ <% child[:children].each do |gchild| %>
+ <li data="level: 3" class="level3"><%= gchild[:title] %>
+ <% if gchild[:children] && gchild[:children].size > 0 %>
+ <ul>
+ <% gchild[:children].each do |ggchild| %>
+ <li data="level: 4" class="level4"><%= ggchild[:title] %></li>
+ <% end %>
+ </ul>
+ <% end %>
+ </li>
+ <% end %>
+ </ul>
+ <% end %>
+ </li>
+ <% end %>
+ </ul>
+ <% end %>
+ </li>
+<% end %>
View
40 support/lib/client.rb
@@ -32,32 +32,34 @@ class Client
attr_accessor :user_id
# metadata api endpoint url
attr_accessor :metadata_server_url
-
- is_retry = false
-
+
def initialize(creds={})
HTTPI.log = false
Savon.configure do |config|
config.log = false
end
- begin
- if ENV["MM_CURRENT_PROJECT_DIRECTORY"] != ''
- yml = YAML::load(File.open(ENV['MM_CURRENT_PROJECT_DIRECTORY'] + "/config/.session"))
- self.user_id = yml['user_id']
- self.sid = yml['sid']
- self.metadata_server_url = yml['metadata_server_url']
- self.endpoint = yml['endpoint']
- self.pclient = get_partner_client
- end
+ if ! creds[:override_session]
+ begin
+ if ENV["MM_CURRENT_PROJECT_DIRECTORY"] != ''
+ yml = YAML::load(File.open(ENV['MM_CURRENT_PROJECT_DIRECTORY'] + "/config/.session"))
+ self.user_id = yml['user_id']
+ self.sid = yml['sid']
+ self.metadata_server_url = yml['metadata_server_url']
+ self.endpoint = yml['endpoint']
+ self.pclient = get_partner_client
+ end
- response = self.pclient.request :get_user_info do
- soap.header = get_soap_header
+ response = self.pclient.request :get_user_info do
+ soap.header = get_soap_header
+ end
+
+ return
+ rescue Exception => e
+ #exception here means most likely that cached auth creds are no longer valid
+ #we're ok with this, the script will attempt another login
+ #raise Exception.new(e.message)
end
- #raise Exception.new(response.to_hash.inspect)
- return
- rescue Exception => e
- #raise Exception.new(e.message)
end
if creds[:sid].nil? && creds[:metadata_server_url].nil?
@@ -76,7 +78,7 @@ def initialize(creds={})
end
begin
- if ENV["MM_CURRENT_PROJECT_DIRECTORY"] != ''
+ if ENV["MM_CURRENT_PROJECT_DIRECTORY"] != '' and ! creds[:override_session]
src = File.new(ENV["MM_CURRENT_PROJECT_DIRECTORY"]+"/config/.session", "w")
src.puts("user_id: " + self.user_id)
src.puts("sid: " + self.sid)
View
70 support/lib/local_server.rb
@@ -23,6 +23,8 @@ def start_test
server.mount('/vc', VersionControlServlet)
server.mount('/auth', AuthenticationServlet)
server.mount('/test', ApexUnitTestServlet)
+ server.mount('/metadata/index', MetadataIndexServlet)
+ server.mount('/deploy', DeployServlet)
server.start
end
@@ -44,6 +46,8 @@ def start
server.mount('/vc', VersionControlServlet)
server.mount('/auth', AuthenticationServlet)
server.mount('/test', ApexUnitTestServlet)
+ server.mount('/metadata/index', MetadataIndexServlet)
+ server.mount('/deploy', DeployServlet)
server.start
end
Process.detach(pid)
@@ -71,11 +75,73 @@ def do_POST(req, resp)
html = ac.render_to_string "unit_test/_test_result", :locals => { :result => result }
resp.body = html
rescue Exception => e
- puts e.message + "\n\n" + e.backtrace.join("\n")
- resp.body = "TEST RESULT: " + test_result.inspect + "\n\n" + "Request: " + req.inspect + "\n\n" + e.message + "\n\n" + e.backtrace.join("\n")
+ #puts e.message + "\n\n" + e.backtrace.join("\n")
+ #resp.body = "TEST RESULT: " + test_result.inspect + "\n\n" + "Request: " + req.inspect + "\n\n" + e.message + "\n\n" + e.backtrace.join("\n")
+ result = {
+ :success => false,
+ :message => e.message
+ }
+ resp.body = result.to_json
end
end
end
+
+ #indexes server metadata to the .org_metadata file in the project config folder
+ class MetadataIndexServlet < WEBrick::HTTPServlet::AbstractServlet
+ def do_GET(req, resp)
+ begin
+ resp['Content-Type'] = 'html'
+ ENV["MM_CURRENT_PROJECT_DIRECTORY"] = req.query["mm_current_project_directory"]
+ do_refresh = req.query["do_refresh"]
+ metadata_array = nil
+ if do_refresh == "true" or do_refresh == true
+ metadata_array = MavensMate.build_index
+ else
+ metadata_array = eval(File.read("#{ENV['MM_CURRENT_PROJECT_DIRECTORY']}/config/.org_metadata")) #=> comprehensive list of server metadata
+ end
+ ac = ApplicationController.new
+ html = ac.render_to_string "deploy/_metadata_tree", :locals => { :meta_array => metadata_array }
+ resp.body = html
+ rescue Exception => e
+ resp['Content-Type'] = 'json'
+ result = {
+ :success => false,
+ :message => e.message + "\n\n" + e.backtrace.join("\n")
+ }
+ resp.body = result.to_json
+ end
+ end
+ end
+
+ class DeployServlet < WEBrick::HTTPServlet::AbstractServlet
+ def do_POST(req, resp)
+ begin
+ resp['Content-Type'] = 'html'
+ ENV["MM_CURRENT_PROJECT_DIRECTORY"] = req.query["mm_current_project_directory"]
+ params = {}
+ params[:un] = req.query["un"]
+ params[:pw] = req.query["pw"]
+ params[:server_url] = req.query["server_url"]
+ params[:package] = eval(req.query["tree"])
+ params[:check_only] = req.query["check_only"]
+ params[:package_type] = "Custom"
+ deploy_result = MavensMate.deploy_to_server(params)
+ html = nil
+ begin
+ result = MavensMate::Util.parse_deploy_response(deploy_result)
+ ac = ApplicationController.new
+ html = ac.render_to_string "deploy/_deploy_result", :locals => { :result => result, :is_check_only => params[:check_only] }
+ rescue
+ html = '<div id="error_message" class="alert-message error"><p><strong>Deployment Failed!</strong></p><p>'+deploy_result[:message]+'</p></div> '
+ end
+ resp.body = html
+ rescue Exception => e
+ result = '<div id="error_message" class="alert-message error"><p><strong>Deployment Failed!</strong></p><p>'+e.message+'</p></div> '
+ resp.body = result
+ end
+ end
+ end
+
class ProjectServlet < WEBrick::HTTPServlet::AbstractServlet
def do_POST(req, resp)
View
123 support/lib/mavensmate.rb
@@ -384,57 +384,30 @@ def self.new_changeset(options={})
#deploys project metadata to a salesforce.com server
def self.deploy_to_server(params)
- validate [:internet, :mm_project]
-
begin
- if params[:mode] == "async"
- endpoint = MavensMate::Util.get_sfdc_endpoint(params[:server_url])
- tmp_dir = MavensMate::FileFactory.put_tmp_directory
- client = MavensMate::Client.new
- if params[:package_type] == "Custom"
- hash = params[:package]
- deploy = true
- MavensMate::FileFactory.put_package(tmp_dir, binding, false)
- zip_file = client.retrieve({ :package => "#{tmp_dir}/package.xml" })
- else
- zip_file = client.retrieve({ :package => "#{ENV['MM_CURRENT_PROJECT_DIRECTORY']}/changesets/#{params[:changeset]}/unpackaged/package.xml" })
- end
- client = MavensMate::Client.new({ :username => params[:un], :password => params[:pw], :endpoint => endpoint })
- result = client.deploy({
- :zip_file => zip_file,
- :deploy_options => "<checkOnly>#{params[:check_only]}</checkOnly><rollbackOnError>true</rollbackOnError>"
- })
- MavensMate::FileFactory.remove_directory(tmp_dir) unless params[:package_type] != "Custom"
- return result
+ endpoint = MavensMate::Util.get_sfdc_endpoint(params[:server_url])
+ tmp_dir = MavensMate::FileFactory.put_tmp_directory
+ client = MavensMate::Client.new
+ if params[:package_type] == "Custom"
+ hash = params[:package]
+ deploy = true
+ MavensMate::FileFactory.put_package(tmp_dir, binding, false)
+ zip_file = client.retrieve({ :package => "#{tmp_dir}/package.xml" })
else
- puts '<div id="mm_logger">'
- TextMate.call_with_progress( :title => "MavensMate", :message => "Deploying to the server") do
- endpoint = MavensMate::Util.get_sfdc_endpoint(params[:server_url])
- tmp_dir = MavensMate::FileFactory.put_tmp_directory
- client = MavensMate::Client.new
- if params[:package_type] == "Custom"
- hash = params[:package]
- deploy = true
- MavensMate::FileFactory.put_package(tmp_dir, binding, false)
- zip_file = client.retrieve({ :package => "#{tmp_dir}/package.xml" })
- else
- zip_file = client.retrieve({ :package => "#{ENV['MM_CURRENT_PROJECT_DIRECTORY']}/changesets/#{params[:changeset]}/unpackaged/package.xml" })
- end
- client = MavensMate::Client.new({ :username => params[:un], :password => params[:pw], :endpoint => endpoint })
- result = client.deploy({
- :zip_file => zip_file,
- :deploy_options => "<checkOnly>#{params[:check_only]}</checkOnly><rollbackOnError>true</rollbackOnError>"
- })
- MavensMate::FileFactory.remove_directory(tmp_dir) unless params[:package_type] != "Custom"
- puts "</div>"
- return result
- end
- end
+ zip_file = client.retrieve({ :package => "#{ENV['MM_CURRENT_PROJECT_DIRECTORY']}/changesets/#{params[:changeset]}/unpackaged/package.xml" })
+ end
+ client = MavensMate::Client.new({ :username => params[:un], :password => params[:pw], :endpoint => endpoint, :override_session => true })
+ result = client.deploy({
+ :zip_file => zip_file,
+ :deploy_options => "<checkOnly>#{params[:check_only]}</checkOnly><rollbackOnError>true</rollbackOnError>"
+ })
+ MavensMate::FileFactory.remove_directory(tmp_dir) unless params[:package_type] != "Custom"
+ return result
rescue Exception => e
- #alert e.message + "\n" + e.backtrace.join("\n")
- puts "</div>"
MavensMate::FileFactory.remove_directory(tmp_dir)
- alert e.message
+ #result = { :success => false, :message => e.message + "\n" + e.backtrace.join("\n") }
+ result = { :success => false, :message => e.message }
+ return result
end
end
@@ -630,41 +603,37 @@ def self.get_project_config
#builds server index and stores in .org_metadata
def self.build_index
- mhash = eval(File.read("#{ENV['TM_BUNDLE_SUPPORT']}/conf/metadata_dictionary"))
+ mhash = eval(File.read("#{SUPPORT}/conf/metadata_dictionary"))
mhash.sort! { |a,b| a[:xml_name].downcase <=> b[:xml_name].downcase }
project_array = []
progress = 0
- threads = []
- TextMate.call_with_progress(:title =>'MavensMate',
- :summary => 'Building server metadata index',
- :details => 'This could take a while, but it\'ll all be worth it!',
- :indeterminate => true ) do |dialog|
- client = MavensMate::Client.new
- mhash.each do |metadata|
- threads << Thread.new {
- thread_client = MavensMate::Client.new({ :sid => client.sid, :metadata_server_url => client.metadata_server_url })
- #progress = progress + 100/mhash.length
- #dialog.parameters = {'summary' => 'Retrieving '+metadata[:xml_name],'progressValue' => progress }
- begin
- project_array.push({
- :title => metadata[:xml_name],
- :key => metadata[:xml_name],
- :isLazy => false,
- :isFolder => true,
- :selected => false,
- :children => thread_client.list(metadata[:xml_name], false, "array"),
- :inFolder => metadata[:in_folder],
- :hasChildTypes => metadata[:child_xml_names] ? true : false
- })
- rescue Exception => e
- puts e.message + "\n" + e.backtrace.join("\n")
- end
- }
- end
- threads.each { |aThread| aThread.join }
- end
+ threads = []
+ client = MavensMate::Client.new
+ mhash.each do |metadata|
+ threads << Thread.new {
+ thread_client = MavensMate::Client.new({ :sid => client.sid, :metadata_server_url => client.metadata_server_url })
+ #progress = progress + 100/mhash.length
+ #dialog.parameters = {'summary' => 'Retrieving '+metadata[:xml_name],'progressValue' => progress }
+ begin
+ project_array.push({
+ :title => metadata[:xml_name],
+ :key => metadata[:xml_name],
+ :isLazy => false,
+ :isFolder => true,
+ :selected => false,
+ :children => thread_client.list(metadata[:xml_name], false, "array"),
+ :inFolder => metadata[:in_folder],
+ :hasChildTypes => metadata[:child_xml_names] ? true : false
+ })
+ rescue Exception => e
+ puts e.message + "\n" + e.backtrace.join("\n")
+ end
+ }
+ end
+ threads.each { |aThread| aThread.join }
project_array.sort! { |a,b| a[:title].downcase <=> b[:title].downcase }
File.open("#{ENV['MM_CURRENT_PROJECT_DIRECTORY']}/config/.org_metadata", 'w') {|f| f.write(project_array.inspect) }
+ return project_array
end
#selects all metadata in tree
View
2  support/lib/util.rb
@@ -2,7 +2,7 @@ module MavensMate
module Util
class << self
- #include MetadataHelper
+ include MetadataHelper
def get_random_string(len=8)
o = [('a'..'z'),('A'..'Z')].map{|i| i.to_a}.flatten;
Please sign in to comment.
Something went wrong with that request. Please try again.