Skip to content

Commit

Permalink
Vlocity Build Tools
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Rutland committed Jan 6, 2017
0 parents commit 31a6a7f
Show file tree
Hide file tree
Showing 23 changed files with 2,558 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

'use strict';
var loadProperties = require('./grunt/loadProperties.js');

var tasksToLoad = [ 'dataPacksJob' ];

module.exports = function(grunt) {
grunt.log.oklns("Vlocity Build Tools");

var properties = loadProperties(grunt);

// Load grunt tasks automatically
require('load-grunt-tasks')(grunt, {pattern: ['grunt-*', '!grunt-template-jasmine-istanbul']});

grunt.initConfig({
properties: properties
});

tasksToLoad.forEach(function(taskName) {
var config = require('./grunt/' + taskName + 'Task.js')(grunt);
if (config) {
grunt.config.merge(config);
}
});

grunt.registerTask("build-js", [ ]);
};
8 changes: 8 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
The MIT License (MIT)
Copyright (c) 2016 Vlocity Inc

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
To begin, fill in the information in the build.properties file, or create your own property file.

sf.username: Salesforce Username
sf.password: Salesforce Password
vlocity.namespace: The namespace of the Vlocity Package. vlocity_ins, vlocity_cmt, or vlocity_ps
vlocity.dataPackJob: The name of the Job being run.

To run a DataPack Job through Ant use the following:
"ant packDeploy" - Deploy the files specified in the Job
or
"ant packExport" - Export from the org to the local file system

Also supports "-propertyfile filename.properties"

To run a DataPack job through Grunt use the following:
grunt -job JOB_FILE_NAME ACTION_NAME

The supported ACTION_NAMEs are as follow:
packDeploy: Deploy all contents of folder in expansionPath
packImport: Import contents of file in buildFile
packExport: Export from all queries and manifest
packBuildFile: Build the buildFile from the expansionPath data
packExpandFile: Create the contents of folders in expansionPath from the buildFile

The files defining Jobs can be found in the dataPacksJobs folder.

For a complete job definition see dataPacksJobs/ReadMe-Example.yaml which includes detailed information on each property.




3 changes: 3 additions & 0 deletions apex/ActivateTemplates.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//include BaseUtilities.cls;

setTemplatesActiveStatus(true);
12 changes: 12 additions & 0 deletions apex/BaseUtilities.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

void setTemplatesActiveStatus(Boolean status)
{
List<vlocity_namespace__VlocityUITemplate__c> layouts = [SELECT Id, Name, Active__c FROM vlocity_namespace__VlocityUITemplate__c];

for (vlocity_namespace__VlocityUITemplate__c layout : layouts)
{
layout.Active__c = status;
}

update layouts;
}
3 changes: 3 additions & 0 deletions apex/DeactivateTemplates.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//include BaseUtilities.cls;

setTemplatesActiveStatus(false);
15 changes: 15 additions & 0 deletions bin/run-grunt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# /bin/sh

echo $@

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm

command -v nvm >/dev/null 2>&1 || { echo >&2 "\nIMPORTANT!!!!\n\nI require NVM to ensure we use the right version of Node.\n\nPlease download the latest NVM from https://github.com/creationix/nvm#installation\n\n\n"; exit 1; }

nvm install
nvm use

npm install
./node_modules/.bin/grunt build-js $*
echo "Grunt completed..."
11 changes: 11 additions & 0 deletions build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Salesforce Username and Password + Security Token
sf.username =
sf.password =
# Your Package's Namespace vlocity_ins, vlocity_cmt, vlocity_ps
vlocity.namespace =
# The Name of the yml manifest file in ./dataPackJobs
vlocity.dataPackJob =

# Please uncomment both if using a Sandbox
#sf.serverurl = https://test.salesforce.com
#sf.loginUrl = https://test.salesforce.com
105 changes: 105 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<project name="VlocityAnt" default="test" basedir="." xmlns:sf="antlib:com.salesforce">

<taskdef resource="net/sf/antcontrib/antlib.xml" classpath="${basedir}/lib/ant-contrib-1.0b3.jar" />

<property environment="env"/>

<!-- If no propertyfile was passed in command line, attempt to load a build.properties if it exists -->
<if>
<not><isset property="sf.username" /></not>
<then>
<trycatch property="buildprop" reference="propbuild">
<try>
<loadproperties srcFile="${basedir}/build.properties"/>
</try>
<catch>
<echo>No propertyfile selected. Please create a "build.properties" file following the template provided in template.build.properties. Or specify a -propertyfile.</echo>
</catch>
</trycatch>
</then>
</if>

<script language="javascript"> <![CDATA[
var commandLine = java.lang.System.getProperty("sun.java.command");
var parts = commandLine.split(' ');
var property = null;
for (var i = 0; i < parts.length; i++) {
if (parts[i] === '-propertyfile') {
// next part is our buildfile for grunt
property = VlocityAnt.createTask("property");
property.setName('grunt.propertyfile');
property.setValue(parts[i+1]);
property.perform();
break;
}
}
if (!property) {
property = VlocityAnt.createTask("property");
property.setName('grunt.propertyfile');
property.setValue('build.properties');
property.perform();
}
]]></script>

<echo> Developer Org - ${sf.username} </echo>
<if>
<isset property="sf.description" />
<then>
<echo> Description - ${sf.description}</echo>
</then>
</if>

<var name="serverurl" unset="true" />
<if>
<not><isset property="sf.serverurl" /></not>
<then>
<property name="serverurl" value="https://login.salesforce.com" />
<property name="sf.serverurl" value="https://login.salesforce.com" />
</then>
<else>
<property name="serverurl" value="${sf.serverurl}" />
</else>
</if>

<var name="maxPoll" unset="true" />
<if>
<isset property="sf.maxPoll" />
<then>
<property name="maxPoll" value="${sf.maxPoll}" />
</then>
<else>
<property name="maxPoll" value="500" />
<property name="sf.maxPoll" value="500" />
</else>
</if>

<target name="packExport" description="">
<runDataPackJob packCommand="packExport" job="${vlocity.dataPackJob}" />
</target>

<target name="packDeploy" description="">
<runDataPackJob packCommand="packDeploy" job="${vlocity.dataPackJob}" />
</target>

<macrodef name="runDataPackJob" >
<attribute name="packCommand" />
<attribute name="job" />
<sequential>
<trycatch property="deployFailureProperty">
<try>
<echo> ------------------------------------------- </echo>
<echo> ------------------------------------------- </echo>
<echo> Running - @{packCommand} - @{job}</echo>
<exec executable="${basedir}/bin/run-grunt" dir="${basedir}">
<arg value="@{packCommand}"/>
<arg value="-job"/>
<arg value="@{job}"/>
<arg value="-propertyfile"/>
<arg value="${grunt.propertyfile}"/>
</exec>
<echo>Finished</echo>
</try>
</trycatch>
</sequential>
</macrodef>
</project>
15 changes: 15 additions & 0 deletions dataPacksJobs/QueryDefinitions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

# Shared Query Definitions

ActiveOmniScripts:
query: Select Id from %vlocity_namespace%__OmniScript__c where %vlocity_namespace%__IsActive__c = true
VlocityDataPackType: OmniScript
ActiveCards:
query: Select Id from %vlocity_namespace%__VlocityUILayout__c where %vlocity_namespace%__Active__c = true
VlocityDataPackType: VlocityUILayout
ActiveTemplates:
query: Select Id from %vlocity_namespace%__VlocityUITemplate__c where %vlocity_namespace%__Active__c = true
VlocityDataPackType: VlocityUITemplate



34 changes: 34 additions & 0 deletions dataPacksJobs/ReadMe-Example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

# The Job defines all the different data for each supported task
# the supported tasks are:
# packDeploy: Deploy all contents of folder in expansionPath
# packImport: Import contents of file in buildFile
# packExport: Export from all queries and manifest and expand at expansionPath
# packBuildFile: Build the buildFile from the expansionPath data
# packExpandFile: Create the contents of folders in expansionPath from the buildFile

projectPath: vlocity.rm.src # Primary project path allows for merging in Property File properties or can be a regular value
expansionPath: datapack-expanded/CampaignBaseTemplates # The Specific Path after the projectPath to insert these Queried Files
buildFile: staticresources/CampaignBaseTemplates.resource # File to create
compileOnBuild: true # Compiled files will not be generated as part of this Export
# You can also run Anonymous Apex before and After a Job by job type.
# Available types are Import, Export, Deploy BuildFile, ExpandFile
# Apex files live in vloc_release/apex or in your projectPath
# You can include multiple Apex files with "//include FileName.cls;" in you .cls file
preJobApex:
Export: DeactivateTemplates.cls
postJobApex:
Export: ActivateTemplates.cls
# Data for Job can be Specified through either queries OR manfifest not both
queries: # Array of Queries to get Data for Job by DataPackType
- VlocityDataPackType: VlocityUITemplate # The VlocityDataPackType the Query is finding Id's for
query: Select Id from %vlocity_namespace%__VlocityUITemplate__c where Name LIKE 'campaign%' # SOQL Query use %vlocity_namespace%__
manifestOnly: false # If true, an Export job will only save items specifically listed in the manifest
manifest: # Object defining Type and Export Data - Can be String or Object
VlocityCard: # VlocityDataPackType
- Campaign-Story # Name
OmniScript: # VlocityDataPackType
- Type: Insurance # This object would export the currently Active OmniScript
SubType: Billing # for this Type/SubType/Language
Language: English
delete: true # Delete the VlocityDataPack__c file on finish
Loading

0 comments on commit 31a6a7f

Please sign in to comment.