UNPKG

build_salesforce_package

Version:

Build Saleforce Package to be deployed using git diff

103 lines (69 loc) 3.01 kB
var Q = require("q"); var fs = require('fs-extra'); var xmlBuilder = require('xmlbuilder'); var chalk = require('chalk'); var AdmZip = require('adm-zip'); class util{ static cmd(exec,cmd,options){ var defer = Q.defer(); exec(cmd,options, function (err, stdout, stderr) { if (stderr != "" && err != "" && err != null) { console.log("ERROR"); defer.reject({err:err, stdout:stdout, stderr:stderr}); } else { defer.resolve(stdout); } }); return defer.promise; } static clean(paths){ for(var key in paths){ if(fs.existsSync(paths[key])){ fs.removeSync(paths[key]); } } } static buildFolders(paths){ for(var key in paths){ if(!fs.existsSync(paths[key])){ fs.mkdirSync(paths[key]); } } } static collect(val, memo) { memo.push(val); return memo; } static buildFolderPath(){ return '.buildFolder'; } static buildPath(){ // playing with the name for this case return util.buildFolderPath()+".xml"; } static buildTargetPath(){ return util.buildFolderPath()+"/build.xml"; } static antSfPath(){ return require("path").join(__dirname, './ant-salesforce.jar'); } static packagePath(){ return util.buildFolderPath()+'/package'; } static retrieveFolderPath(){ return util.buildFolderPath()+'/retrieveCode'; } static asBundle(){ return ['Territory2Model','AuraDefinitionBundle']; } static foldersType(){ return ['territory2Models','LeadConvertSettings','appMenus','applications','approvalProcesses','assignmentRules','autoResponseRules','certs','classes','communities','customMetadata','dashboards','delegateGroups','documents','email','escalationRules','flexipages','flowDefinitions','flows','groups','homePageLayouts','installedPackages','labels','layouts','letterhead','matchingRules','namedCredentials','objectTranslations','objects','pages','pathAssistants','permissionsets','postTemplates','profiles','quickActions','reportTypes','reports','roles','settings','sharingRules','staticresources','tabs','territory2Types','translations','triggers','workflows','aura']; } static metaTypes(){ return ['Territory2Model','LeadConvertSettings','AppMenu','CustomApplication','ApprovalProcess','AssignmentRules','AutoResponseRules','Certificate','ApexClass','Community','CustomMetadata','Dashboard','DelegateGroup','Document','EmailTemplate','EscalationRules','FlexiPage','FlowDefinition','Flow','Group','HomePageLayout','InstalledPackage','CustomLabels','Layout','Letterhead','MatchingRules','NamedCredential','CustomObjectTranslation','CustomObject','ApexPage','PathAssistant','PermissionSet','PostTemplate','Profile','QuickAction','ReportType','Report','Role','Settings','SharingRules','StaticResource','CustomTab','Territory2Type','Translations','ApexTrigger','Workflow','AuraDefinitionBundle']; } static configPath(){ return require("path").join(__dirname, "config.json"); } } module.exports = util;